By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,795 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,795 IT Pros & Developers. It's quick & easy.

History of short-curcuited AND

P: n/a
In recent weeks, I've twice come upon people who consider the short-
curcuited evaluation of logical && (and ||) to be just a vendor-
defined compiler quirk, and recommend against depending on it.

To help me reason with these people, can anyone here:

1) Verify that short-curcuit evaluation is specified in the orginal
K&R "C Programming Lanuage" (I only have the ANSI 2ed)

2) Can anyone recall a early C compiler where this was this was broken?

Mar 22 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
James Curran wrote:
In recent weeks, I've twice come upon people who consider the short-
curcuited evaluation of logical && (and ||) to be just a vendor-
defined compiler quirk, and recommend against depending on it.

To help me reason with these people, can anyone here:

1) Verify that short-curcuit evaluation is specified in the orginal
K&R "C Programming Lanuage" (I only have the ANSI 2ed)

2) Can anyone recall a early C compiler where this was this was broken?
This should probably go to comp.lang.c.

--
Ian Collins.
Mar 22 '07 #2

P: n/a
James Curran wrote:
In recent weeks, I've twice come upon people who consider the short-
curcuited evaluation of logical && (and ||) to be just a vendor-
defined compiler quirk, and recommend against depending on it.

To help me reason with these people, can anyone here:

1) Verify that short-curcuit evaluation is specified in the orginal
K&R "C Programming Lanuage" (I only have the ANSI 2ed)

2) Can anyone recall a early C compiler where this was this was broken?
To hell with K&R, ISO/IEC 14882:2003 5.14/1 guarantees short circuit
evaluation for &&, and 5.15/1 guarantees short circuit evaluation for
||, with the caveat that a user-defined operator&& or operator|| throws
that out the window (see footnote 12 to 1.9/18).
And yes, the 1978 edition of K&R specified short-circuit, in discussion
of the "Word Counting" program between exercises 1-8 and 1-9 (page 19 in
my copy).
Mar 22 '07 #3

P: n/a
On Mar 22, 4:55 pm, red floyd <no.s...@here.dudewrote:
To hell with K&R, ISO/IEC 14882:2003 5.14/1 guarantees short circuit
But I really need the historical prospective to be able to say
"it's never been anyway else", because one of the people I was talking
to about this was actually refering to C#, where the difference
between "specified in the Standard" and "vendor defined complier
quirk" is a bit vague.
>
And yes, the 1978 edition of K&R specified short-circuit, in discussion
of the "Word Counting" program between exercises 1-8 and 1-9 (page 19 in
my copy).
Thanks! That's to it.

Mar 22 '07 #4

P: n/a
James Curran wrote:
On Mar 22, 4:55 pm, red floyd <no.s...@here.dudewrote:

>>To hell with K&R, ISO/IEC 14882:2003 5.14/1 guarantees short circuit


But I really need the historical prospective to be able to say
"it's never been anyway else", because one of the people I was talking
to about this was actually refering to C#, where the difference
between "specified in the Standard" and "vendor defined complier
quirk" is a bit vague.
Aren't they one and the same? :)

--
Ian Collins.
Mar 22 '07 #5

P: n/a
In article <11*********************@l75g2000hse.googlegroups. com>,
James Curran <ja**********@gmail.comwrote:
>2) Can anyone recall a early C compiler where this was this was broken?
I believe that && and || were reversed in some versions of csh around
4.3BSD or so. Perhaps that is what triggered this line of thought??

Marcus Hall
ma****@tuells.org
Mar 23 '07 #6

P: n/a
marcus hall wrote:
In article <11*********************@l75g2000hse.googlegroups. com>,
James Curran <ja**********@gmail.comwrote:
>2) Can anyone recall a early C compiler where this was this was broken?

I believe that && and || were reversed in some versions of csh around
4.3BSD or so. Perhaps that is what triggered this line of thought??
It happened in 4.2. The problem was that the csh guys kept the 0 =
false, but 0 indicated command success, so the sense of the conditionals
reversed in csh.
Mar 23 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.