Tony Arcieri wrote:
>> BTW in all your posts on the topic, you don't seem to address pre-
>> increment vs post-incrememt.  (Forgive me if I'm wrong.)  If Ruby
>> implemented ++ and didn't address that, it wouldn't be C or C++
>> semantics at all.
>>
> 
> That's a can of worms I've been trying to avoid, as there are lexing/parsing
> ambiguities surrounding the combination of both.  How do you parse a+++b vs
> a++++b vs a+++++b?

The only sane answer is to do what C does, as far as parsing. But the 
deeper problem in ruby is what do pre- and post- really mean? In C there 
are expressions and there are other constructs, so we can define natural 
boundaries for pre and post in terms of expressions. In ruby we have 
mostly expressions. So the hard questions are "before what?" and "after 
what?"

Does

   foo {x++}

yield the incremented x to foo, or the original x? What if foo yields 
several times? Increment once, or once per iteration?

What about

   x = 0
   y = case; when true; x++; end

Is y 0 or 1?

It's kind of an ink-blot test for what you think "expression" means, but 
of course everything is an expression in ruby.

It's not an answer to say

   'x++' should have the same effect as 'x+=1'

because that's not even true in C.

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407