> Is it too late for Ruby 1.9 to support lambdas that look like > > \ p1, p1 -> { block } Not being a Haskell user, I have to ask: did you mean to write a block with two parameters, like this? \ p1, p2 -> { block } If not, it's a violation of DRY :-) To me, backslash looks like an escaping operator (in strings and regexps, or avoiding newline splits). So personally I find it ugly and unnatural. As an example, presumably we talking about writing doit(\ p1, p2 -> { p1 + p2 }, \ msg -> { puts msg }) instead of doit(lambda { |p1, p2| p1 + p2 }, lambda { |msg| puts msg }) ? I generally use proc{...} anyway, even if it does have slightly different semantics. You could always take a leaf out of Paul Graham's book: http://www.paulgraham.com/arcll1.html "in Arc, lambda is called fn. This idea appalled me at first, but it seemed like fn would be shorter and at least as expressive. What if I was just used to lambda? So, with a queasy sense of duty, I decided to try it. And after a few days I actually liked fn better. Now it seems clear to me that lambda is an onion: Alonzo Church himself wouldn't have used it if he had to write out the word lambda each time." But at the end of the day, I'd vote for removing alternative syntaxes altogether. It becomes harder to sell Ruby if there are too many equivalent but different idioms to learn. That's unless it's part of a grand unification plan (e.g. block parameters gain optional/default arguments, and def methods become blocks). But I don't think that's the case here. Regards, Brian.
on 01.05.2008 09:51
on 01.05.2008 13:03
On Thu, May 1, 2008 at 9:50 AM, Brian Candler <B.Candler@pobox.com> wrote: > But at the end of the day, I'd vote for removing alternative syntaxes > altogether. It becomes harder to sell Ruby if there are too many > equivalent > but different idioms to learn. > yeah. I'd vote for removing the "do end" syntax for blocks too ;). I always found it hard to visually distinguish blocks from other constructs like if and for when they are written as "do .... end" as compared to { ... }. So I became a do-end hater. But as I know there are a lot of people who love do-end there is probably no way to remove them from the language. -- henon
on 01.05.2008 17:00
Hi -- On Thu, 1 May 2008, Meinrad Recheis wrote: > and for when they are written as "do .... end" as compared to { ... }. So I > became a do-end hater. But as I know there are a lot of people who love > do-end there is probably no way to remove them from the language. They're also not identical to {}: irb(main):001:0> puts [1,2,3].map do |x| x * 10 end 1 2 3 irb(main):002:0> puts [1,2,3].map {|x| x * 10 } 10 20 30 David