On Monday 01 December 2003 05:03 pm, T. Onoma wrote:
> On Monday 01 December 2003 03:49 pm, Yukihiro Matsumoto wrote:
> > I like the basic idea.  the "shortcut notation" would be a key.  I
> > couldn't think of a good one for years.  But someone might be able to.
>
> If I understand correctly,
>
> In ruby-core:1792, Mathieu Bouchard hints at:
>
>   { || ... }  -or-  { |*| ... }
>
> Could something like that work? Or would it be too ambiguious with blocks?

From what I understand, the problem with the above shorthand for procs is 
this:

  def a(x=nil)
    x.call if a('call')
    yield('block') if block_given?
  end

  a {|z| puts "which? #{z}"}

It occured to me today that it's rather odd that blocks can be passed to any 
method whether the method uses the block or not. --a method need not 
explictly state it takes a block, as it does with everyhting else. It really 
is odd if you think about it. What if you could do that with any argument? 
Imagine having arguments always passed in to a special keyword, args, and 
using parameters_given? :-) LoL! Cracks me up! I guess I shouldn't laugh too 
much though. In fact having a keyword like args anyway could cetainly be 
useful (since we can always count on the name). Imagine:

  def a(*)
    puts args.join(', ')
  end

Well, I suppose it's a little too late to rethink explict acceptance of block 
parameters now. So then. Is there any other way to resolve the above problem? 
Short of a YAP (Yet Another Perlism), the general census hasn't been able to  
provded one. But there is one possibility which, seems to me, might actually 
work just fine: let blocks take precedence over lambda parameters. A clsely 
related concern is already an appearent consideration given the binding rules 
the differentiate {...} and do..end. And it makes sense since you can always 
unambiguate it with parenthesis when need be:

  a( {|z| puts "which? #{z}"} )

It wouldn't break old code either since currently the keyword method proc or 
lambda is used in the cases in which it otherwise could, eg.
  
  a proc { |z| ... }

So if we want a shorthand for lambdas, the already used concise notation of  
{ || ... } in fact does offer a good solution, and weighs in to stave-off Yet 
Another Perlism.

T.