cond. op. on ='s LHS
Chris Dollin
kers at hplb.hpl.hp.com
Fri Feb 15 20:25:33 AEST 1991
Someone (I've lost the attribution) asked how people felt about:
> *(a==b?&c:&d) = 1;
>
>instead of:
>
> if (a==b) c=1;
> else d=1;
I'll add my agreement; the first one is "Ugh". But .. how would people feel if
conditionals could deliver lvalues, ie, so that
(a == b ? c : d) = 1;
was legal and had the obvious meaning? (Clearly, when c, d, and especially 1
are more complex expressions, you might wish to make it abundantly clear that a
*single* value was being assigned to one or other localtion.)
If anyone sees fit to respond to this, I suggest they switch newsgroups to
comp.lang.misc, as it will no longer be much to do with C ...
--
Regards, Kers. | "You're better off not dreaming of the things to come;
Caravan: | Dreams are always ending far too soon."
More information about the Comp.lang.c
mailing list