On 10/18/05, Trans <transfire / gmail.com> wrote:
> > >   lambda [|x| ... ]
> >
> > No. That's even uglier than the first.
>
> When you consider all the other proposals, this really stands out as
> the *least* ugly way it could be done, and have suggested it too.

Well, I'm glad ~someone~ likes it :)

> Unfortuantely it has one major problem. It is ambigious with #[]
> method.

I see. So these would be ok:

  (1..10).map[|x| x * x]
  (1..10).map [|x| x * x]

but this is ambiguous:

  (1..10).each[ puts "Hello"  ]

OK - I see that - it conflicts with the :[] method, as in:

  (1..10).to_a[ 1 ]

> To overcome you'd either have to always use a space before the
> block or always incldue the bars ||. Both suck.

So either
  (1..10).each[|| puts "Hello" ]
  (1..10).each [|| puts "Hello" ]
or
  (1..10).each [ puts "Hello" ]

I doubt that a space is sufficient to disambiguate it from an array
parameter, e.g. in

  (1..10).my_each [ puts "Hello" ]

  class Range
    def my_each(*args, &block)
      #...args = [ puts "Hello" ] or block = [ puts "Hello" ]?
    end
  end

So that knocks that on the head. And I recall a certain amount of
apoplexy regarding the double bars. Best not stir up that nest of
hornets again ;)

> Of course with Matz'
> perly notation,
>
>  ->(x=4)[ ... ]
>
> That problem goes away too ;)
>
> T.

If only it were that easy!

Regards,

Sean