Increment / Decrement Operator Behavior

Dejan Lekic dejan.lekic at gmail.com
Wed Jun 6 03:55:50 PDT 2012


On Tue, 05 Jun 2012 10:23:18 +0200, Mikael Lindsten wrote:

> 2012/6/5 Jonathan M Davis <jmdavisProg at gmx.com>
>>
>>
>> I think that Bernard is being a bit harsh, but in essence, I agree.
>> Since the
>> evaluation order of arguments is undefined, programmers should be aware
>> of that
>> and code accordingly. If they don't bother to learn, then they're going
>> to get
>> bitten, and that's life.
>>
>> Now, Walter _has_ expressed interest in changing it so that the order
>> of evaluation for function arguments is fully defined as being
>> left-to-right, which solves the issue. I'd still council against
>> getting into the habit of writing code which relies on the order of
>> evaluation for the arguments to a function, since it's so common for
>> other languages not to define it (so that
>> the compiler can better optimize the calls), and so getting into the
>> habit of
>> writing code which _does_ depend on the order of evalution for function
>> arguments will cause you to write bad code you when you work in most
>> other programming languages.
>>
>> As for treating pre or post-increment operators specially in some
>> manner, that
>> doesn't make sense. The problem is far more general than that. If we're
>> going
>> to change anything, it would be to make it so that the language itself
>> defines
>> the order of evaluation of function arguments as being left-to-right.
>>
>> - Jonathan M Davis
>>
>>
> Agree completely!
> <div class="gmail_quote">2012/6/5 Jonathan M Davis <span
> dir="ltr"><<a href="mailto:jmdavisProg at gmx.com"
> target="_blank">jmdavisProg at gmx.com</a>></span><blockquote
> class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc
> solid;padding-left:1ex"> <div class="HOEnZb"><div class="h5">
> <br>
> </div></div>I think that Bernard is being a bit harsh, but in essence, I
> agree. Since the<br> evaluation order of arguments is undefined,
> programmers should be aware of that<br> and code accordingly. If they
> don't bother to learn, then they're going to get<br> bitten, and
> that's life.<br>
> <br>
> Now, Walter _has_ expressed interest in changing it so that the order
> of<br> evaluation for function arguments is fully defined as being
> left-to-right,<br> which solves the issue. I'd still council against
> getting into the habit of<br> writing code which relies on the order of
> evaluation for the arguments to a<br> function, since it's so common
> for other languages not to define it (so that<br> the compiler can
> better optimize the calls), and so getting into the habit of<br> writing
> code which _does_ depend on the order of evalution for function<br>
> arguments will cause you to write bad code you when you work in most
> other<br> programming languages.<br>
> <br>
> As for treating pre or post-increment operators specially in some
> manner, that<br> doesn't make sense. The problem is far more general
> than that. If we're going<br> to change anything, it would be to
> make it so that the language itself defines<br> the order of evaluation
> of function arguments as being left-to-right.<br> <span
> class="HOEnZb"><font color="#888888"><br> - Jonathan M Davis<br>
> </font></span></blockquote></div><br><div>Agree
> completely!</div><div><br></div>


Ah noes, my eyes... HTML code... :-(


-- 
Dejan Lekic
  mailto:dejan.lekic(a)gmail.com
  http://dejan.lekic.org 


More information about the Digitalmars-d mailing list