Hi,

In message "Re: Default argument values for blocks"
    on Wed, 12 Oct 2005 10:01:44 +0900, Eric Mahurin <eric_mahurin / yahoo.com> writes:

|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?

They are same, same class, same behavior, except for full argument
syntax of method arguments.

|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.

I think this issue should _not_ be solved by making new lambda-like
object, but something like making eval a keyword, so that non
referenced local variable can be erased unless eval is called within
the scope.

|- 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.

In 1.9, you can declare block local variables explicitly, by the
syntax:

  foo {|a; b, c| ...}   # b and c are block local

so that

  b=1
  5.times{|i;b|
    b=5         # modifying in-block "b"
    p [i,b]
  }
  p b           # outer "b" remain unchanged

|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.

See above.

							matz.