History of short-curcuited AND

J

James Curran

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?
 
I

Ian Collins

James said:
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.
 
R

red floyd

James said:
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).
 
J

James Curran

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.
 
I

Ian Collins

James said:
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? :)
 
M

marcus hall

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
(e-mail address removed)
 
R

red floyd

marcus said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top