Aaron Sherman writes: : On Fri, 2002-05-03 at 12:37, Larry Wall wrote: : > Piers Cawley writes: : > : Consider the following. : > : : > : sub foo {...} : > : : > : foo *@ary; : > : foo * @ary; : > : : > : Is this another place where whitespace will have meaning? Or should I : > : add parentheses to disambiguate? Enquiring minds want to know. : > : > I see no ambiguity. It's a unary * in either case. You'd have to : > declare it : > : > sub foo () {...} : > : > to get a multiply out of it. : : Ok, I'm not going to say you're wrong (I most likely am), but I would : like to try to understand why this would be true. : : The tokenizer is going to hand back what? 'bareword:foo', '*', 'type:@', : 'identifier:ary'?
It's not yet clear whether Perl 6 will actually have a tokenizer separate from the parser. : In which case, it seems to me that you would be right, but there's a big : trap.... Does that mean that if foo has the following: : : sub foo(); : sub foo($x,$y); : : Then you always get multiply, or you always get argument expansion? Is : that going to be counter-intuitive for the programmer who uses a library : that provides such a definition? Frankly, I don't know what that does yet, though obviously the argumentless declaration cannot be allowed to disable the parsing of other calls with arguments. Likely we'll just say that overloading a name like that disables the argumentless bareword syntax, and you'd have to explicitly pass zero arguments somehow. Some might argue that we should just try to parse the long one and revert to the short one if the long one fails to parse, but I'd like to avoid arbitrarily long lookahead as much as possible. Nevertheless, if, as planned, we use Perl 6 regexes to write the parser, backtracking is a possibility. I just don't think this is a good application for it. Some would argue there's never a good application for it when it comes to computer languages, but I think "computer" languages are misnamed. They're really human languages that we translate to the real computer language of bits. And natural human languages do make use of backtracking occasionally. Larry