Submitted by grenzi (Wed Jan 14 07:01:07 UTC 2004)
..} requires to enclose the variable beetween a couple of "|". We may just use a single one, as in SmallTalk or Groovy
do |a,b,c| .. endto
do a,b,c | .. end
you would just need:
ary.map {x| x.succ} instead of ary.map {|x| x.succ}
Possibly we could introduce the change as a parallel syntax, leaving both available. Warning:
This may cause ambiguity in cases like this
is it 'a' a formal argument or a reference to an external variable BitOR'ed with b ?
a=0; b=1 proc { a | b }
not a big deal for really rare cases.
a=0;b=1 proc {| a|b }
If both syntax are available this may be hard to check. We could be forced to write
proc { || a|b}
for this case
Comments | Current voting | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
The ambiguities introduced into this grammar make it a very undesirable change, IMO. The initial pipe makes the grammar easier to parse, and easier to read--and I think ease of readability should come before ease of writability. Saving a single keystroke is not worth the added complexity and potential visual ambiguities.
- Jamis Buck
Thanks, James. I feel same way. Actually, in the pre-relase phase (back in 1993), the block parameter syntax was exactly what you described here. I changed the syntax for the particular reason which James stated above.
-matz.
I did not mind about parsing efficiency cause we're going to have a bytecompiled form for our script sometime in the future. But It seem I'm the only one that finds the proposed new syntax more clear than the old. Ok, let's kill this rcr :)
- grenzi