Re: Iterator Syntax
by Buggs other posts by this author
May 8 2002 12:11PM messages near this date
Re: Iterator Syntax
|
Re: Iterator Syntax
On Wednesday 08 May 2002 05:57, Mathieu Bouchard wrote:
> On Wed, 8 May 2002, Buggs wrote:
> > On Tuesday 07 May 2002 16:24, Glen Starchman wrote:
> > > On Tuesday 07 May 2002 02:47 am, Donal K. Fellows wrote:
> > > "hello".each(3) { |x| print ("chars=%s", x)
> >
> > what about
> > "hello".each(3)->x {print ("chars=%s", x)}
> > if you still have "->" spare
> > think
> > x <-"hello".each(3) {print ("chars=%s", x)}
> > is funny
>
> putting the block parameters at the beginning of the block syntax like
> {|x| ... } is well-justified: those parameters belong to the block, not to
> the call. This is why the same kind of syntax was chosen in languages like
> Smalltalk, Self, and Ruby.
>
> The params belong to the block because it makes it easier to pass the
> blocks around from call to call, or store them in variables.
Well of course that is a fine point,
but how does one explain from an aesthetic view
how the parameter gets its values ?
And also there is the isomorphy with methods' parameters being outside
of the block (at least in Ruby i think).
Buggs
Thread:
Glen Starchman
Donal K. Fellows
Glen Starchman
Pixel
Glen Starchman
Buggs
Mathieu Bouchard
Buggs
Mathieu Bouchard
Glen Starchman
|