--- Yukihiro Matsumoto <matz / ruby-lang.org> wrote:

> Hi,
> 
> In message "Re: Default argument values for blocks"
>     on Wed, 12 Oct 2005 02:40:48 +0900, "Ara.T.Howard"
> <Ara.T.Howard / noaa.gov> writes:
> 
> |>  foo = ->(foo="bar"){puts foo}
> 
> |-> means lambda?
> 
> Yes, as in Perl6.  "lambda" here means lambda in other
> languages, not
> the lambda method in Ruby.
> 
> 							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). 
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. 
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.




	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com