On Thursday, August 5, 2004, 7:11:29 AM, Jesse wrote:

> In article <138135881306.20040805010035 / soyabean.com.au>, Gavin
> Sinclair <gsinclair / soyabean.com.au> wrote:

>> On Wednesday, August 4, 2004, 10:41:43 PM, Jesse wrote:
>> 
>> > Between Ruby and Lisp? To tell the truth I'm not entirely sure. The
>> > pickaxe book does a lousy job explaining the differences between blocks
>> > and proc objects. I'm still not sure why Ruby needs two concepts when
>> > Lisp and other languages get by with one. I also don't know why Ruby
>> > uses that weird yield syntax.
>> 
>> On the one hand you advocate macros to make syntax more expressive; on
>> the other you advocate rolling everything back into anonymous
>> functions with no visual distinctions.  *shrug*

> Well, what are the differences between blocks and proc objects? As far
> as I can tell the only difference is that proc objects are explicitly
> declared in method argument lists and are first class objects. Blocks,
> on the other hand, are not listed in the method list (unless you use
> &block to create a proc) and called using yield.

> How does that make the language more expressive?

Which do you prefer?

   (1..10).map { |n| n ** 2 }

   (1..10).map( lambda { |n| n ** 2 } )

(If the latter, then I guess nothing further can be said.)

Blocks are something that are used _all the time_ in Ruby.  Perhaps
more than you appreciate.  They are semantically the same as explicit
blocks, but the syntax is optimised for the common use.  And it's not
limiting:

  square = lambda { |n| n ** 2 }
  (1..10).map(&square)

Please remember Joel's "percent-case" solution, extensively using
blocks.  That was nothing if not expressive.  Ruby can be bent into
1000 different shapes, primarily thanks to blocks.  Those shapes would
be possible without them (just use explicit lambdas) but not nearly as
appealing, and therefore people wouldn't bother, and the world would
be poorer.

> Implicitly passing arguments seems actively bad and using "yield lhs
> rhs" seems worse than using "compare.call lhs rhs".

Same comments as above apply.  "Yield" is the perfect English word to
describe the behaviour.

For some words from the source, I recommend you look up Matz's
interviews with Bill Venners on artima.com.

Ruby is a lot of things, but it's not a LISP/Dylan wanna-be.  You do
yourself no favours by insisting on looking at it from that angle.

Cheers,
Gavin