For Programmers: Free Programming Magazines  


Home > Archive > AWK > November 2004 > evaluation order with increment operators









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author evaluation order with increment operators
Robert Katz

2004-11-29, 3:58 pm

Is there any ambiguity in the following?

while (k < j) print B[++k]

Is it possible that k will be incremented before the while loop is checked?

--
Regards,

---Robert
Bob Harris

2004-11-29, 3:58 pm

In article <C1dod.3295$pX.2941@news.cpqcorp.net>,
Robert Katz <katz@hp.com> wrote:

> Is there any ambiguity in the following?
>
> while (k < j) print B[++k]
>
> Is it possible that k will be incremented before the while loop is checked?


It should not. Yours should be no difference than

while (k < j)
print B[++k]

or

while (k < j) {
print B[++k]
}

If ++K happens before k < j then it should be wrong.

Bob Harris
William James

2004-11-29, 3:58 pm

Robert Katz <katz@hp.com> wrote

> Is there any ambiguity in the following?
>
> while (k < j) print B[++k]
>
> Is it possible that k will be incremented before the while loop is checked?


No.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com