From: Eric Mahurin Date: 2005-08-05T08:36:25+09:00 Subject: Re: new block notation (was: Re: ruby-dev summary 26468-26661) --- "Ara.T.Howard" wrote: > On Fri, 5 Aug 2005, Eric Mahurin wrote: > > > --- Yukihiro Matsumoto wrote: > > > >> Hi, > >> > >> In message "Re: new block notation (was: Re: ruby-dev > summary > >> 26468-26661)" > >> on Fri, 5 Aug 2005 03:23:40 +0900, Brian Wisti > >> writes: > >> > >> |Aww, but now it looks even less like Smalltalk! I kid, I > >> will live > >> |just fine with either notation style, although I prefer > the > >> current > >> |style. I'll keep on using the current style for as long > as > >> it is > >> |available, for one simple reason: less punctuation. > >> > >> That's OK. The new notation is to replace lambda. > >> > >> matz. > > > > I noticed this experimental behavior disappeared: > > > > f = { ... code .. } > > > > So this new syntax tries to address 2 issues: > > > > 1. Allowing args to have defaults in a block. > > > > 2. Making a lambda without the "lamda", "proc", or > "Proc.new" > > ... and also not cause ambiguities with a Hash. > > > > So before, the experiment was this (no default args and > > ambiguities with Hash): > > > > f = { |a| ... } > > > > and now you are thinking about this: > > > > f = ->(a) { ... } > > how about something a little more mathematical > > f <- {|a = 42| p a} > > or even > > f <= {|a = 42, b <= {p 42}| p a; b.call } > > so <- or <= mean 'function assignment' > > probably someone already suggested this... this thread has > been long ;-) Wouldn't work: a. doesn't solve the problem that the default "value" can be an expression that has a "|" in it. b. you can do more with lambda's other than just assign them. You can pass them as arguments, call their methods (i.e. arity, call), and in general they should just be another object in an expression. Treating the assignment of a lambda special this way doesn't make sense. c. the <= form looks like the less than or equal operator. ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs