A while back, I started using Ruby for some personal software projects. I was immediately impressed with its "code block" syntax. It's a fairly natural Algol-like syntax for lambda expressions, and is used to great effect in the language. (
I'd like to advocate wider adoption of this kind of syntax, and suggest some improvements. )
Comments 5
Reply
I think Ruby's blocks are full closures, although I'm not super clear on the meaning of that phrase. But, for example:
irb(main):001:0> i = 1
=> 1
irb(main):002:0> p = Proc.new { i += 1 }
=> #
irb(main):003:0> p.call()
=> 2
irb(main):004:0> i
=> 2
Reply
It seems roughly equivalent to the difference between lamba and progn.
Reply
Reply
Reply
Leave a comment