🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #482

A question about the tertiary (? : ) operator

#482
From: Steve Hosgood
Date: Fri, 18 Aug 1989 14:54
25 lines
1510 bytes
I never noticed until last night that the conditional operator:

<condition>? <val1>: <val2>

..is not a valid lvalue, even if both <val1> and <val2> are lvalues!
I wanted to say:

(flag > 0? foo: bar) = <complex expression>;

..which didn't work, needless to say. I had to employ a temporary variable
and an 'if' statement in the end :-(.

Is there a good reason for this behaviour?
Thanks in advance
Steve

-----------------------------------------------+------------------------------
Steve Hosgood BSc,                             | Phone (+44) 792 295213
Image Processing and Systems Engineer,         | Fax   (+44) 792 295532
Institute for Industrial Information Techology,| Telex 48149
Innovation Centre, University of Wales,        | JANET: iiitsh@uk.ac.swan.pyr
Swansea SA2 8PP                                | UUCP: ..!ukc!cybaswan!iiitsh
-----------------------------------------------+------------------------------
            My views are not necessarily those of my employers!
           Please note the change in my username as of 1 Aug '89
Technical Details
Message-ID: <612@cybaswan.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!ukc!reading!cf-cm!cybaswan!iiitsh

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!ukc!reading!cf-cm!cybaswan!iiitsh
From: iiitsh@cybaswan.UUCP (Steve Hosgood)
Newsgroups: comp.std.c
Subject: A question about the tertiary (? : ) operator
Keywords: tertiary, lvalue, ternary
Message-ID: <612@cybaswan.UUCP>
Date: 18 Aug 89 14:54:49 GMT
Organization: Institute for Industrial Information Technology
Lines: 25