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


Groups > comp.lang.c++ > #82251

Re: That's while I love C++ over C

From Manfred <noname@add.invalid>
Newsgroups comp.lang.c++
Subject Re: That's while I love C++ over C
Date 2021-11-06 19:12 +0100
Organization Aioe.org NNTP Server
Message-ID <sm6gj5$1k40$1@gioia.aioe.org> (permalink)
References (5 earlier) <sm4fpi$hk3$1@dont-email.me> <f6d1797e-35f4-4f84-901d-011e2335c77dn@googlegroups.com> <874k8qaual.fsf@bsb.me.uk> <sm4s6u$jog$1@redfloyd.dont-email.me> <87cznda6ej.fsf@bsb.me.uk>

Show all headers | View raw


On 11/6/2021 12:08 PM, Ben Bacarisse wrote:
> red floyd <no.spam.here@its.invalid> writes:
> 
>> On 11/5/2021 7:32 PM, Ben Bacarisse wrote:
>>> Tony Oliver <guinness.tony@gmail.com> writes:
>>>
>>>> On Friday, 5 November 2021 at 23:47:14 UTC, Bart wrote:
>>>>> On 05/11/2021 23:24, red floyd wrote:
>>>>>> On 11/5/2021 3:25 PM, Lynn McGuire wrote:
>>>>>>> On 11/5/2021 4:59 PM, Vir Campestris wrote:
>>>>>
>>>>>> [insanely ugly, unreadable, and unmaintainable code fragments redacted]
>>>>> You're having a laugh I think.
>>>>>
>>>>> My code fragments,
>>>>
>>>> which are [insanely ugly, unreadable, and unmaintainable code fragments]
>>>> are not welcome in clc++.
>>> I find the "fire them" remarks very odd.  Quite apart from the fact that
>>> I'd hope everyone enjoys better employment protection than that, what's
>>> so bad about conditionally choosing an assignment target compared to
>>> conditionally choosing an assigned value?  Or is any use of a conditional
>>> operator a sacking offence?
>>
>> No, use of the conditional operator is not a sacking offense.  Even when
>> used as an lvalue.  However, as I said above, I'd insist on training for
>> the person.  That is highly unmaintainable code.
>>
>> If I had to use something like that,  It would be:
>>
>> int *pInt = (x == y ? &a : &b);
>> *pInt = c;
>>
>> But I'd really prefer
>>
>> if (x == y)
>>     a = c;
>> else
>>     b = c;
>>
>> You've just inherited some code.  Which would you prefer to maintain?
> 
> The shorter and clearer
> 
>    (x == y ? a : b) = c;
> 
> I can see at a glance that the same thing is always assigned (no need to
> check two places though when it's just 'c' that's not hard), and I can
> see instantly that what is determined by the test is the destination.
> 

Beauty is in the eye of the beholder. I guess you like puzzles, so to 
your eyes this is quite clear, while others not as familiar with this 
construct harshly label it as unmaintainable.

FWIW, to me the construct looks just a bit spicy, which is still good.
Expecially since the "odd" part is having the ternary on the LHS, but 
even for those for which it is not immediate to grok, it still can't be 
misinterpreted(*), so for me it's a pass too.

(* I mean, if a reader would have to struggle figuring out what is the 
destination between a/b or x/y, they'd have a much bigger problem than 
the writer)

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


Thread

That's while I love C++ over C Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-03 20:39 +0100
  Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-03 20:28 +0000
    Re: That's while I love C++ over C Vir Campestris <vir.campestris@invalid.invalid> - 2021-11-05 21:59 +0000
      Re: That's while I love C++ over C Lynn McGuire <lynnmcguire5@gmail.com> - 2021-11-05 17:25 -0500
        Re: That's while I love C++ over C red floyd <no.spam.here@its.invalid> - 2021-11-05 16:24 -0700
          Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-05 23:46 +0000
            Re: That's while I love C++ over C Tony Oliver <guinness.tony@gmail.com> - 2021-11-05 17:48 -0700
              Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-06 01:40 +0000
              Re: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 02:32 +0000
                Re: That's while I love C++ over C red floyd <no.spam.here@its.invalid> - 2021-11-05 20:18 -0700
                Re: That's while I love C++ over C "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2021-11-06 04:48 +0100
                Re: That's while I love C++ over C James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-11-06 00:34 -0400
                Re: That's while I love C++ over C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-11-05 22:48 -0700
                Re: That's while I love C++ over C red floyd <no.spam.here@its.invalid> - 2021-11-05 22:26 -0700
                Re: That's while I love C++ over C Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-06 07:37 +0100
                Re: That's while I love C++ over C Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-06 07:36 +0100
                Re: That's while I love C++ over C Ike Naar <ike@sdf.org> - 2021-11-06 06:59 +0000
                Re: That's while I love C++ over C David Brown <david.brown@hesbynett.no> - 2021-11-06 11:12 +0100
                Re: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 11:08 +0000
                Re: That's while I love C++ over C Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-06 15:03 +0100
                Re: That's while I love C++ over C Manfred <noname@add.invalid> - 2021-11-06 19:12 +0100
                Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-06 18:57 +0000
                Re: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 20:50 +0000
                Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-06 11:44 +0000
                Re: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 13:18 +0000
            Re: That's while I love C++ over C David Brown <david.brown@hesbynett.no> - 2021-11-06 10:58 +0100
              Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-06 12:00 +0000
                Re: That's while I love C++ over C Öö Tiib <ootiib@hot.ee> - 2021-11-06 07:04 -0700
                Re: That's while I love C++ over C David Brown <david.brown@hesbynett.no> - 2021-11-06 15:50 +0100
            Re: That's while I love C++ over C scott@slp53.sl.home (Scott Lurndal) - 2021-11-06 14:43 +0000
              [OT] Algol68 Was: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 17:13 +0000
                Re: [OT] Algol68 Was: That's while I love C++ over C scott@slp53.sl.home (Scott Lurndal) - 2021-11-06 20:16 +0000
                Re: [OT] Algol68 Was: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 20:25 +0000
          Re: That's while I love C++ over C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-11-05 21:59 -0700
            Re: That's while I love C++ over C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-11-05 22:23 -0700
              Re: That's while I love C++ over C red floyd <no.spam.here@its.invalid> - 2021-11-05 22:27 -0700
                Re: That's while I love C++ over C red floyd <no.spam.here@its.invalid> - 2021-11-05 22:28 -0700
                Re: That's while I love C++ over C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-11-05 22:46 -0700
                Re: That's while I love C++ over C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-11-05 22:46 -0700
                Re: That's while I love C++ over C David Brown <david.brown@hesbynett.no> - 2021-11-06 12:25 +0100
                Re: That's while I love C++ over C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-11-06 13:27 -0700
                Re: That's while I love C++ over C Manfred <noname@add.invalid> - 2021-11-07 00:38 +0100
                Re: That's while I love C++ over C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-07 00:33 +0000
                Re: That's while I love C++ over C David Brown <david.brown@hesbynett.no> - 2021-11-07 15:10 +0100
                Re: That's while I love C++ over C James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-11-08 01:47 -0500
      Re: That's while I love C++ over C Bart <bc@freeuk.com> - 2021-11-05 23:35 +0000
      Re: That's while I love C++ over C Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-06 07:33 +0100

csiph-web