From: David Alan Black Date: 2002-04-28T06:38:17+09:00 Subject: Re: $_ if no |var| Hi -- On Sun, 28 Apr 2002, Lars Christensen wrote: > On Sun, 28 Apr 2002, David Alan Black wrote: > > > I have to confess that to me it just doesn't look or feel like Ruby. > > I know that's very vague... that's why I was trying to come up with a > > case illustrating the importance (or at least Ruby-ness) of all the > > assignments being made, independent of any branching within the code > > of the block. > > I think you are right--I think I would 'expect' all assignments to be > made. I.e. > > proc { if |a| then |b| else |c| end } > > should only be syntatic sugar for > > proc { |a,b,c| if a then b else c end } > > or, equivalently > > proc { |p| a,b,c=p; if a then b else c end } > > The |a| would just be syntax to mark which symbols should be bound to the > arguments when the block is evaluated. I honestly don't think this syntax can scale beyond trivial cases. You're talking about binding variables in the order they're used in the block, rather than binding them in a particular order and then using them. I think there's a major impedance mismatch between this idea and the possibilities of Ruby syntax. Consider, for example: proc { |a,b,c| if a then b else c } proc { |a,b,c| unless a then c else b } which are equivalent. But these: proc { if |arg1| then |arg2| else |arg3| } proc { unless |arg1| then |arg2| else |arg3| } would not be. Could it be there's a reason that most (all?) languages grab their method/function/proc parameters up front? :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav