Re: Benefit of not defining the order of execution
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 17 Feb 2009 08:35:29 -0800
nick_keighley_nospam@xxxxxxxxxxx writes:
On 14 Feb, 04:51, Tim Rentsch <t...@xxxxxxxxxxxxxxxxxxx> wrote:[...]
I know only that the person who wrote the code didn't think it was
important to force a particular order of evaluation.
or just didn't think. Most programmers assume left to right
evaluation and would be quite surprised if they were told they
were wrong.
"Most programmers"? If that statement is based on actual data, that's
interesting (and disappointing); if not, it would be good to see some
actual data.
[...]
Now consider the case where the language specifies a left-to-right
evaluation order. Let's look again at the example line. Now I have
to wonder if g() and h() interact;
this is crazy! You claim that making the code more predictable
makes the code harder to analyse!
(The context was a = f( g(x), h(y) );.)
If you assume a sufficiently competent programmer, you can assume
that g(x) and h(y) don't interact, because if they did then the
programmer wouldn't have written that statement. On the other hand,
"sufficiently competent" may approach "never makes mistakes".
On the other other hand, g(x) and h(y) *shouldn't* interact; if they
do, nailing down the order of evaluation makes the code well-defined,
but still poor style.
[...]
--
Keith Thompson (The_Other_Keith) kst@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: Benefit of not defining the order of execution
- From: nick_keighley_nospam
- Re: Benefit of not defining the order of execution
- From: Richard Harter
- Re: Benefit of not defining the order of execution
- From: Kaz Kylheku
- Re: Benefit of not defining the order of execution
- References:
- Benefit of not defining the order of execution
- From: somenath
- Re: Benefit of not defining the order of execution
- From: Kaz Kylheku
- Re: Benefit of not defining the order of execution
- From: Tim Rentsch
- Re: Benefit of not defining the order of execution
- From: nick_keighley_nospam
- Benefit of not defining the order of execution
- Prev by Date: Re: Searching for history of "#if"
- Next by Date: Re: va_list * and function parameters?
- Previous by thread: Re: Benefit of not defining the order of execution
- Next by thread: Re: Benefit of not defining the order of execution
- Index(es):
Relevant Pages
|