e1?(void_e2):(void_e3)

Davidsen davidsen at steinmetz.UUCP
Sat Aug 16 02:12:07 AEST 1986


In article <1701 at mmintl.UUCP> franka at mmintl.UUCP (Frank Adams) writes:
>The other paradigm is that e1?e2:e3 is precisely one of e2 or e3, depending
>on the value of e1.  This is a very reasonable interpretation; but if it
>were correct, there would be one other important consequence which is not in
>fact legal.  This is that when e2 and e3 are lvalues, the compound
>expression should also be an lvalue.  In particular, one could write
>
>e1?e2:e3 = e4;
>
>which would mean the same thing as
>
>if (e1) then e2 = e4; else e3 = e4;
>

This kicked off an interesting thought:
  *(e1 ? <ptr expr> : <ptr expr>) = expr;

Lo and behold it does what the quoted expression indicates. In an
actual example:
  *(a < b : &b : &a) = 70;

I'm not sure it *good* for anything, but if I do it with macros using
cute names, I can enter it in the obfuscated C contest...
-- 
	-bill davidsen

  ihnp4!seismo!rochester!steinmetz!--\
                                       \
                    unirot ------------->---> crdos1!davidsen
                          chinet ------/
         sixhub ---------------------/        (davidsen at ge-crd.ARPA)

"Stupidity, like virtue, is its own reward"



More information about the Net.bugs mailing list