--- Yukihiro Matsumoto said:
Hi,
=20
In message "Re: Default argument values for blocks"
on Wed, 12 Oct 2005 02:40:48 +0900, "Ara.T.Howard"
=20
|> foo =3D ->(foo=3D"bar"){puts foo}
=20
|-> means lambda?
=20
Yes, as in Perl6. "lambda" here means lambda in other
languages, not
the lambda method in Ruby.
=20
matz.
Other than syntax, what's the difference between this and the
Proc that comes from the lambda method? Maybe how return,
break, etc is handled?
In addition to handling defaults in arguments, I think these
issues need to be addressed in blocks/lambdas:
- all variables in the defining scope of a block/lambda are
prevented from being GCed by the block/lambda (because of the
#binding). This can easily result in a leaky program if not
careful. I discussed several solutions to this in a previous
thread.
- a facility for making variables local (regardless of whether
a variable of the same name exists in the defining scope).=20
This would also be good to have for a begin-end type block (I'd
like to have it for making inlined macros where I don't want to
worry about what variables are already used). I discussed
several solutions for this in another thread.
Also, I saw some slides for ruby 2 back in 2003 showing that
arguments will always be local to the block and other variables
in the block will be in the same scope as the defining scope.=20
I think always making arguments local is a good thing, but
never localizing the other variables will be problematic if
another local variable facility is not provided.
=09
=09
__________________________________=20
Yahoo! Mail - PC Magazine Editors' Choice 2005=20
http://mail.yahoo.com