Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #94068

Re: lvalues from the ternary op

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: lvalues from the ternary op
Date 2016-09-26 01:10 +0100
Organization A noiseless patient Spider
Message-ID <8737kned1h.fsf@bsb.me.uk> (permalink)
References <c8677aed-7589-4ba4-9aa0-8b20b00c0981@googlegroups.com>

Show all headers | View raw


luser droog <luser.droog@gmail.com> writes:

> Just came up with this. Probably foolish nonsense as usual.

No, I think it's a reasonable thing to do.  C++ thought so too, to the
extent of making it easier.  But it's not technically "lvalues from the
ternary op".  It's just lvalues from the * op -- the result of a *
expression is always an lvalue.

> I was looking over the (obfuscated) code of my 8086 emulator
> and my eyes fell upon this statement.
>
> https://github.com/luser-dr00g/8086/blob/b7bfb134c1146cbe2ac7f1b80dd521e0ddb2349c/a8086.c#L112
> d?y+=*fl&CF:(x+=*fl&CF);
>
> And I thought: There's a lot of repetition in the two cases.
> So what about:
>
> *(d?&y:&x)+=F(CF);

C++ allows you to write (d ? y : x) += F(CF); directly.  I'm not sure
why C doesn't, but it seems a shame to me that it doesn't.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

lvalues from the ternary op luser droog <luser.droog@gmail.com> - 2016-09-25 16:12 -0700
  Re: lvalues from the ternary op "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-25 19:58 -0400
  Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-26 01:10 +0100
    Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-27 15:01 -0700
      Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-28 00:23 +0100
        Re: lvalues from the ternary op BartC <bc@freeuk.com> - 2016-09-28 01:35 +0100
        Re: lvalues from the ternary op "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-28 12:39 -0400
          Re: lvalues from the ternary op BartC <bc@freeuk.com> - 2016-09-28 18:23 +0100
        Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-08 15:37 -0700
  Re: lvalues from the ternary op supercat@casperkitty.com - 2016-09-25 18:14 -0700
  Re: lvalues from the ternary op BartC <bc@freeuk.com> - 2016-09-26 10:51 +0100
    Re: lvalues from the ternary op luser droog <luser.droog@gmail.com> - 2016-09-26 12:42 -0700

csiph-web