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


Groups > comp.lang.c > #94073

Re: lvalues from the ternary op

From BartC <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: lvalues from the ternary op
Date 2016-09-26 10:51 +0100
Organization A noiseless patient Spider
Message-ID <nsar29$9gs$1@dont-email.me> (permalink)
References <c8677aed-7589-4ba4-9aa0-8b20b00c0981@googlegroups.com>

Show all headers | View raw


On 26/09/2016 00:12, luser droog wrote:
> Just came up with this. Probably foolish nonsense as usual.
>
> 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);

I don't quite understand. You seem to be adding *fl&CF to either x or y 
depending on d. So why not:

  *(d?&y:&x) += (&fl&CF);

Why is it necessary to introduce F(CF)? Or is it also about repetition 
of *fl&CF within that set of macros? (Which doesn't appear too serious 
to me as they are just a set of macros; the repetition isn't in the 
actual code.)

BTW if you're that keen on macros then why not:

#define SETC(a,b,c) *((a)?&(b):&(c))

SETC(d,x,y) += (&fl&CF);

At least SETC (or whatever more suitable name is used) is of more 
general use.

-- 
Bartc

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