Austin Ziegler wrote:
> This is not what was discussed on Friday during the roundtable or on
> Saturday during the keynote. Both were suggested to solve the same
> problem -- that is, the same problem that is currently solved in 1.9
> with:
>
>   anon = ->(x = 5) { ... }
>
> I think that a *lot* of people really don't like that notation. Too many
> symbols, lack of a left-side for the arrow, etc. But my sense of the
> room was that either using def() or lambda() was generally felt to be
> cleaner and as meaningful. Using def(), however, means that "def" is
> contextually closure/non-closure depending on the presence of a name. It
> also seemed to me that Matz wasn't fond of the reuse of "def".

I would have to agree with matz actually.

> I have yet to need one (an anonymous function). I personally don't
> believe that it would necessarily be more efficient, either. Indeed,
> with my use of #map, etc., I tend to liberally use the fact that no new
> scope is introduced and that the block is a closure. I think that your
> estimation of which would be more useful flies contrary to current use
> and likely continued future use of Ruby.
>
> Indeed, I don't think that I'd ever use the lambda() keyword that has
> been proposed to replace ->() in 1.9. I could be wrong, but that's just
> not my programming style. I almost certainly wouldn't use one that gives
> me an anonymous non-closure function. I don't think that that's an
> important enough use case, where a named method would work just as well.
>
> Others may find it more useful, but I haven't had a need yet.

In many cases I don't think it would matter which was used. So if
non-closure is at all more efficient that's agood thing. Either way I
have come across situations where I NEED non-closure, but there is
currently no reasonable  way to do it.

> [...]
> >>  lambda do |x|
> >>    # ... has closure
> >>  end
> >>
> >>  lambda do(x)
> >>    # ... does not have closure
> >>  end
> > I quite like that. While we're at it, how about
>
> I can't stand it. It's entirely too contextual and "magic". If you
> really *must* have non-closure anonymous functions, propose a keyword.
> Magic punctuation doesn't do it for me. IMO, there's just a little too
> much magic punctuation in Ruby as it stands now. (Not much, but I'm not
> really comfortable with **kwargs.)

I agree with you on both accounts. I don;' think it's a good idea, but
perhaps it might stimulate some better ideas. And I concur **kwargs is
stinky.

> >   lambda {|x| .. }
> >
> > for closure and
> >
> >   lambda [|x| ... ]
>
> No. That's even uglier than the first.

When you consider all the other proposals, this really stands out as
the *least* ugly way it could be done, and have suggested it too.
Unfortuantely it has one major problem. It is ambigious with #[]
method. To overcome you'd either have to always use a space before the
block or always incldue the bars ||. Both suck. Of course with Matz'
perly notation,

  ->(x=4)[ ... ]

That problem goes away too ;)

T.