cond. op. on ='s LHS

Richard Harter rh at smds.UUCP
Sat Feb 23 15:06:25 AEST 1991


In article <1210 at sheol.UUCP>, throopw at sheol.UUCP (Wayne Throop) writes:
> > rh at smds.UUCP (Richard Harter)

> [.. discussing assignment to expressions like *(a==b?&c:&d) ..]
> > First of all the trick of using
> > *(cond?&var1:&var2) is not technically legal since the result of the
> > ?: is not an lvalue.  [Harbison & Steele].  I rather suspect you could
> > sneak it past most compilers though.

> As Dan Bernstein has pointed out in another article, Richard is
> incorrect here.  While it is true that the result of ?: is never
> an lvalue, this is irrelevant since the result of * always is.	

Mea culpa, remove foot from mouth, etc.  Actually, as other articles
have pointed out there are some fine points, depending on whether you
are talking about paleolithic C, neo-modern classic C, or ANSI C.
However the cited remark was a bit of all wrong.

As far as the ?: syntax is concerned I would like to reiterate the point
that it is dissimilar to other C constructs (other than that it uses still
more special symbols.)  All other operators which use punctuation (with
the exception of ->) are either unary or binary operators.  All conditional
operations, except for ?:, use words, e.g. if, else, while, etc.  It is
a wart.
-- 
Richard Harter, Software Maintenance and Development Systems, Inc.
Net address: jjmhome!smds!rh Phone: 508-369-7398 
US Mail: SMDS Inc., PO Box 555, Concord MA 01742
This sentence no verb.  This sentence short.  This signature done.



More information about the Comp.lang.c mailing list