--0016e64c260856ad630477e948e7
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Nov 8, 2009 at 9:54 PM, Joel VanderWerf <vjoel / path.berkeley.edu>wrote:

> The only sane answer is to do what C does, as far as parsing.


You will find the answer to these edge cases varies.  Fortunately they are
edge cases...


> But the deeper problem in ruby is what do pre- and post- really mean?


Really?


> In C there are expressions and there are other constructs,


As someone intimately familiar with the expression/statement barrier, I
really don't see the issue...


> so we can define natural boundaries for pre and post in terms of
> expressions. In ruby we have mostly expressions.


Ruby is a pure expression-based language (and I see you acknowledge that
later in this message).  There are no statements which don't return a value.


> So the hard questions are "before what?" and "after what?"
>
> Does
>
>  foo {x++}
>
> yield the incremented x to foo, or the original x?


Well, to be pedantic, foo is yielding.  The return value of the block in
this case is original x.


> What if foo yields several times? Increment once, or once per iteration?
>

Once per iteration.


> What about
>
>  x  
>  y  ase; when true; x++; end
>
> Is y 0 or 1?
>

0


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

Funny, earlier you implied there were things that aren't expressions in Ruby
:)


> It's not an answer to say
>
>  'x++' should have the same effect as 'x+
>
> because that's not even true in C.


Correct, it's ++x that would have the same effect as x + , not that I find
the preincrementation vs postincrementation distinction particularly useful
in Ruby, which is why I've advocated picking the canonical one and going
with that, even though preincrementation has semantics which would make more
sense in Ruby.

I'm trying to be pragmatic... and yet being dismissed out of hand.  Because
it is not Ruby-like!  According to certain people's definitions of
"Ruby-like"...

-- 
Tony Arcieri
Medioh/Nagravision

--0016e64c260856ad630477e948e7--