On Mon, Jun 16, 2003 at 06:09:57AM +0900, you CAN teach an old dog ... wrote:
> Mauricio FernŠŌdez <batsman.geo / yahoo.com> wrote in message 
> 
> > The point was that the "normal way" (with lambdas but not blocks la
> > Ruby) would be
> >   my_func(bar, baz, block) 
> > ie. passing the lambda explicitly and having to use block.call inside
> > my_func, instead of having yield call the "implicit block".
> Exactly what my question was intended to ask. So, it's been an
> interesting discussion around blocks and yield, but any answer(s) to
> the question:
> 
> What is the reason for the implicit block syntax?

Only matz can give an authoritative answer, but here's my guess: by
having one block passed for free (*), use of that feature is encouraged
and that affects our perception of the language (iterators & co.).

(*): there's a small "psychological" cost in using a block, as
 * you don't have to care about the closing ')' being far away from the
   opening '('
 * you don't have to keep inventing names for the blocks as they're
   anonymous

It'd be a real PITA to have to do
  some_block = { |x| .... }
  bla.each(some_block)
and 
  bla.each({|x| ....
     ....
	 ....
	 ....
  }) #notice the ')'
is even worse.

That's less of an issue on the "block receiving side", but yield instead
of block.call is still more convenient.

> And, along the way, any answers to my question (on a separate thread)
> about why
>    def ... end 

There were some proposals for changes in that area for 1.8.

> returns nil, instead of some kind of method object; and 
>    class ... end
> returns the last expression, also instead of some kind of class
> instance.

We use that to access things in that scope, for instance
 class << self; self end.instance_eval { ... }
which you do sometimes need.
-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux
over the wire". Film at 11.'
	-- Linus Torvalds