> [EMAIL PROTECTED] (Damian Conway) writes: > > But in Perl 6, the consistency between a method's parameter list and its > > argument list *is* checked at run-time, so passing the wrong number of > > arguments is (quite literally) fatal. > But wait! If we can check how many parameters to pass, we know how > many parameters to pass; problem solved. Sure, the parser has to stay > in a superposition of states until the check is made, but we're close > to requiring quantum supercomputers to run this thing anyway.
That works, with one big proviso. You have to have predeclared all possible methods in the class to which the object belongs, AND each method in that class (and all defined subclasses) has to have a unique signature. All right, that's two provisos, but the first is probably already a given. Consider: # Excuse my crummy Perl6 syntax, but you know what I mean. class B { method bar($x, $y) { # mumble . . . } method bar($z) { # note 1 # different mumble . . . } # . . . other methods such as new . . . } my B $foo .= new(); # With parens, these are unambiguous. @abc = ($foo.bar(3, 4)); @abc = ($foo.bar(3), 4); # So which is this? @abc = ($foo.bar 3, 4); Now this case might be manageable, but what if the two-argument bar() is in class D instead, and D inherits from B? My point is that in this case parentheses are needed to disambiguate which method needs to be called. You could avoid the parentheses if you made the above example illegal by requiring that all methods with the same name in a class hierarchy have the same signature (specifically, the same number of arguments), but that seems somewhat unPerlish, and even more restrictive than C++ (not a good thing). The fact that parentheses are not needed when passing arguments to regular household functions seems to imply to me that it isn't possible to declare two functions with the same name and different signatures (like C++ function overloading). Otherwise the ambiguity would strike again. I'm uneasy about how the whole parentheses thing sits when multimethods are brought into the equation, but then I'm uneasy about multimethods in the first place. I don't mind if people practise that kind of thing in the privacy of their own homes, but not out in public, please. > I'm afraid I can't tell whether or not I'm being serious any more. Damian, you broke Simon! How could you? -- Debbie Pickett http://www.csse.monash.edu.au/~debbiep [EMAIL PROTECTED] "My words, your expression. My land, always your possession. My song, your production. My expense is always your deduction." - _You Don't Believe_, The Alan Parsons Project