On Tue, 10 Dec 2002 13:02:18 -0800, Brent Dax wrote: > Peter Haworth: > # @b = @a.grep { /\S/ }, $c; > # > # how does the compiler know whether $c is an argument to grep, > # or another element to be assigned to @b? > > The same way it does when it sees a normal sub? > > I know, late binding and all that. But when you think about it, a lot > can be done to simulate the conditions otherwise. For example, with a > definition like this: > > class Foo { > method bar($self: $baz) { ... } > } > > And a call like this: > > @b=$foo_obj.bar $baz, $quux; > > Where we can see *at runtime* that $quux is too many arguments, we can > just append it to the end of bar()'s return value. (This would only > happen when there were no parentheses.)
But at runtime, we don't necessarily have a good idea of what the original code looked like (we've compiled to bytecode, and the user may have stripped all the useful metadata from the .pbc file), or a way to generate new bytecode on the fly (the user may have opted to exclude the runtime eval capability). For this to work, we'd have to compile every possible variation of the syntax tree, and decide which of them was appropriate at runtime. Ick. In a strictly typed language you can do this without too many surprises. I don't think it's appropriate for Perl, except possibly for certain special cases like blocks as the only argument. -- Peter Haworth [EMAIL PROTECTED] 'As Annie Oakley almost said, "Anything you can do, I can do meta."' -- Larry Wall