On Fri, Mar 14, 2003 at 09:30:06AM -0500, Dan Sugalski wrote:
> Still... What exactly about A6 did you dislike? It's a bit big, but
> there's nothing in it that seemed particularly controversial or
> foolish to me, and I tend to get cranky with the new features.
How 'bout this one. (I mean to bring it up on perl6-langage or
somewhere, but I haven't done my homework yet, so I'll float it
here.)
A6 says that, as in Perl 5, only anonymous subs are closures. I've
always thought of the fact that Perl 5 named subs are not closures
as a bug kept for compatibility. It prevents this nice programming
style (example in Perl 5 because I'm sure I would botch Perl 6):
sub foo
{
my ($x, $y, $z) = @_;
sub helper
{
... $x $y $z ...
}
...
... helper() ...
... helper() ...
...
}
In Perl 5 you can get around this by assigning an anon sub to a glob
ref (ugh), and in Perl 6 it appears you will be able to assign it to
a normal lexical variable (better), but neither is as nice as just
declaring a sub. Given that Perl 6 will even have lexically scoped
subs, it's seems perverse that they would not also be closures.
Besides, if such subs aren't closures, what is the semantics of
accessing a lexical variable from the outer scope? It seems that
the only alternatives to closure are Perl 5 "variable will not stay
shared"--which is unspeakably ugly and the source of much
confusion--or error.
So, why aren't all subs, or at least lexical subs, closures?
Andrew
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm