On Fri, Jun 13, 2003 at 07:31:47PM +0900, Robert Klemme wrote:
> Newsbeitrag news:a6e48b6b.0306120851.45c29db7 / posting.google.com...
> > What is the reason for the implicit block in Ruby invocations?
> 
> What's an "implicit block"?  From the wording I'd assume you mean a block
> that is not explicitely mentioned and is somehow generated.  But your
> example shows an explicite written block.
> 
> > Is it purely syntactic sugar, to allow things to look 'built-in'
> >
> >    my_func bar, baz  { ... block ... }
> 
> Hm, what do you mean by "built in"?  Do you mean that by omitting the
> brackets around arguments to "my_func" it looks like a keyword?

My bet is that he means
  my_func bar, baz { ... block ... }
as opposed to
  block = proc { ... block .., }
  my_func(bar,baz, &block)  # or my_func(bar,baz,block) and having to
                            # explicitly use block.call instead of the
                            # implicit block w/ yield

IMHO it can be considered syntactic sugar used to pass an anonymous
function (lambda) to a method, but because it is so convenient it
pervades all of Ruby, first in the libs and then in my (our) code. 

After having internal iterators and blocks, having to do
  Enumeration e = bla.keys();
  while(e.hasMoreElements) {
    MyClass bla = (MyClass) e.nextElement();

  }
is a PITA (for me, at least).

Syntactic sugar does make a difference in the way we use things and IMHO
this is a part of the "Ruby way".

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

The most important design issue... is the fact that Linux is supposed to 
be fun...
	-- Linus Torvalds at the First Dutch International Symposium on Linux