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


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

Re: two's complement idea

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c++
Subject Re: two's complement idea
Date Fri, 10 Jan 2020 20:44:18 -0800
Organization A noiseless patient Spider
Lines 108
Message-ID <8636cm4n6l.fsf@linuxsc.com> (permalink)
References <qppva0$cbj$1@news.albasani.net> <chine.bleu-5DC1AD.19552804112019@reader.eternal-september.org> <qpqv6g$kc3$1@dont-email.me> <86tv7dcfxr.fsf@linuxsc.com> <a2c1701c-c742-4cb6-92b7-e18df807f83e@googlegroups.com> <8636e7bvog.fsf@linuxsc.com> <qrpkc3$47r$1@dont-email.me> <86o8wk3zef.fsf@linuxsc.com> <8ef21e91-6984-44d1-8585-568b245c5924@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
Injection-Info reader02.eternal-september.org; posting-host="a658bb27d1b88b897660621da5fe7a9e"; logging-data="25741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19K4FSNpTKN6UJPxXxdLInkDAVegV/nSTU="
User-Agent Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock sha1:X0VgDFoIxSf8NN/iYT348c+OlrU= sha1:XaJGTKYi+lVm8XqBIcvYI39OVGo=
Xref csiph.com comp.lang.c++:71272

Show key headers only | View raw


Öö Tiib <ootiib@hot.ee> writes:

> On Saturday, 7 December 2019 17:53:56 UTC+2, Tim Rentsch  wrote:
>
>> "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:
>>
>>> On 28.11.2019 21:19, Tim Rentsch wrote:
>>>
>>>>  <<D6 F6 [05b6]>>  Tiib <ootiib@hot.ee> writes:
>>>>
>>>>> On Saturday, 9 November 2019 15:55:38 UTC+2, Tim Rentsch  wrote:
>>>>>
>>>>>> "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:
>>>>>>
>>>>>>> On 05.11.2019 03:55, Siri Cruise wrote:
>>>>>>>
>>>>>>>> In article <qppva0$cbj$1@news.albasani.net>,
>>>>>>>>    Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> What would realls speak against that numieric_limits<type> would
>>>>>>>>>  {} include
>>>>>>>>> a flag whether a type has a two's complement and maybe another flag
>>>>>>>>>  {} that
>>>>>>>>> says that a type has a two's complement wrap-around?
>>>>>>>>
>>>>>>>> #define ONESCOMPLEMENT (-1==~1)
>>>>>>>> #define TWOSCOMPLEMENT (-1==~0)
>>>>>>>
>>>>>>> Nice idea.
>>>>>>>
>>>>>>> But please use `constexpr` or `const` declarations, not macros.
>>>>>>>
>>>>>>> Using macros conveys the idea that macros are a reasonable solution to
>>>>>>> the problem of naming a compile time constant.
>>>>>>
>>>>>> Why do C++ fans hate the C preprocessor so much?
>>>>>
>>>>> It is not hate.  We prefer to use macros when what these do can not
>>>>> be done as simply by using inline functions, templates or constants.
>>>>>
>>>>> Reasons are that macros are names that ignore scope and work on
>>>>> textual substitutions.  Macros are harder to debug and cause
>>>>> unanticipated effects and confusion in clumsy hands.  However for
>>>>> teams that manage to hire members with godly hands macros are
>>>>> fine. :D
>>>>
>>>> [snip] here, the shortcomings [of macros] don't apply?
>>>
>>> They do.
>>>
>>> For example, regarding what was mentioned about scope, you generally
>>> can't have two libraries that both define `ONESCOMPLEMENT`. Perhaps
>>> library A defines it as above but library B defines it to produce a
>>> one's complement.
>>
>> A macro may be defined in places other than public libraries.  Or
>> if it is defined in a public library, and a possible ambiguity is
>> important to remove, it's easy enough to prefix the macro name
>> with the namespace used for the library.  Would you have the same
>> objection to using a macro if the macro were not defined in a
>> public library?
>
> The authors of libraries are often competitors and so do not like
> that you pick and integrate best of breed from their products.
> The bigger ones seemingly even enjoy introducing such conflicts
> and contradictions.  Sometimes even with standard library.  Anyone
> targeting Windows had sooner or later to look up what to do with
> min and max macros in windows.h.
>
>>> Perhaps both define it as above but using library B you get a
>>> redefinition warning.
>>
>> I don't know why you think that.  Giving several identical
>> definitions for a macro is allowed in C90, C99, C11, C++98,
>> C++03, C++11, C++14, and C++17.  Testing with gcc, clang, g++,
>> and clang++ gave no diagnostics even with -Wall and -Wextra.
>
> Libraries next to never define macro identical to letter and so
> tests show opposite:
> <http://coliru.stacked-crooked.com/a/65fc657ef88c80fa>
> What you suggest to do with these annoying warnings?  Silence?
> Branch library code?  Get the authors to cooperate?
>
>>> And for example, regarding the so far not mentioned visual
>>> impact, the shouting uppercase is an annoying eyesore.
>>
>> But that has nothing to do with the macro processor.  You are
>> perfectly free to choose a name that is not all uppercase, or
>> even all lowercase, if you'd rather.  What you said might be an
>> argument about how to name a macro but it is not an argument
>> about whether to use a macro.
>
> I agree.  We can just configure our tools and text editors to show
> macros with different color if we for some reason want these to stand
> out visually at all.  However lot of coding standards have those rules
> in and so majority of macros that we face are in SCREAMING_CAPS.
>
>> Taking all of these together, the objections given sound more
>> like rationalizations trying to justify an overarching dislike of
>> macros than objectively reasoned conclusions.
>
> Sure, if you dismiss all problems (that we have tired of facing in
> practice) with claim that those do not exist then answering to your
> question why we avoid macros is impossible.

Your comments are not really about macros but about how various
people misuse macros.  Any language feature can be misused.
My question is about macros, not about people who misuse them.

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


Thread

Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-11-28 12:19 -0800
  Re: two's complement idea "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-11-29 00:14 +0100
    Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2019-11-29 09:15 +0100
      Re: two's complement idea Bo Persson <bo@bo-persson.se> - 2019-11-29 10:58 +0100
        Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2019-11-29 12:49 +0100
    Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-12-07 07:53 -0800
      Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2019-12-07 08:22 -0800
        Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-10 20:44 -0800
          Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-10 23:44 -0800
            Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-14 07:08 -0800
              Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-14 08:42 -0800
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-21 02:09 -0800
                Re: two's complement idea James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-21 05:14 -0800
                Re: two's complement idea Daniel <danielaparker@gmail.com> - 2020-01-21 13:08 -0800
                Re: two's complement idea James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-22 00:07 -0500
                Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-21 23:21 -0800
                Re: two's complement idea Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-22 01:51 -0800
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-22 11:28 +0100
                Re: two's complement idea Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-22 11:52 +0100
                Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-22 04:47 -0800
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-04-02 07:19 -0700
                Re: two's complement idea James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-04-02 08:07 -0700
                Re: two's complement idea boltar@nowhere.org - 2020-01-21 16:44 +0000
                Re: two's complement idea Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-21 20:01 +0000
                Re: two's complement idea boltar@nowhere.org - 2020-01-22 11:26 +0000
                Re: two's complement idea Christian Gollwitzer <auriocus@gmx.de> - 2020-01-22 20:04 +0100
                Re: two's complement idea Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-22 11:30 -0800
                Re: two's complement idea Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2020-01-22 19:57 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-23 10:03 +1300
                Re: two's complement idea boltar@nowhere.org - 2020-01-23 09:24 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-24 07:29 +1300
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-23 10:03 +1300
                Re: two's complement idea "Fred. Zwarts" <F.Zwarts@KVI.nl> - 2020-01-23 10:09 +0100
                Re: two's complement idea boltar@nowhere.org - 2020-01-23 09:29 +0000
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-24 01:08 +0000
                Re: two's complement idea boltar@nowhere.org - 2020-01-24 12:27 +0000
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-24 01:06 +0000
                Re: two's complement idea Bo Persson <bo@bo-persson.se> - 2020-01-24 10:07 +0100
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-01-24 11:36 +0200
                Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-24 17:34 -0800
                Re: two's complement idea Siri Cruise <chine.bleu@yahoo.com> - 2020-01-24 17:57 -0800
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-24 12:19 +0000
                Re: two's complement idea Bo Persson <bo@bo-persson.se> - 2020-01-24 14:19 +0100
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-24 14:11 +0000
                Re: two's complement idea Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-24 17:26 +0000
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-24 17:35 +0000
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-01-24 22:27 +0200
                Re: two's complement idea James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-24 23:21 -0500
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-25 11:06 +1300
                Re: two's complement idea Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-24 22:12 +0000
                Re: two's complement idea James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-24 23:24 -0500
                Re: two's complement idea Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-25 09:04 +0000
                Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-25 04:15 -0800
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-25 19:55 +0100
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-25 00:05 +0100
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-25 01:19 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-25 19:50 +1300
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-25 11:57 +0000
                Re: two's complement idea Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2020-01-25 13:42 +0000
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-25 14:58 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-26 07:58 +1300
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-25 20:34 +0100
                Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-25 12:41 -0800
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-01-26 16:08 +0200
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-27 02:20 -0800
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-01-27 15:03 +0200
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-02-15 06:44 -0800
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-03-06 10:18 +0200
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-04-02 07:05 -0700
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-04-02 20:03 +0300
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-04-04 12:37 -0700
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-26 07:45 +1300
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-25 19:56 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-26 09:49 +1300
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-25 21:33 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-26 11:00 +1300
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-25 22:23 +0000
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-26 11:46 +1300
                Re: two's complement idea Paavo Helde <myfirstname@osa.pri.ee> - 2020-01-26 10:55 +0200
                Re: two's complement idea Öö Tiib <ootiib@hot.ee> - 2020-01-26 03:47 -0800
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-27 01:28 -0800
                Re: two's complement idea Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-25 22:22 +0000
                Re: two's complement idea James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-25 18:24 -0500
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-26 12:54 +0100
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-26 12:44 +0000
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-26 14:58 +0100
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-26 14:53 +0000
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-26 19:10 +0100
                Re: two's complement idea Robert Wessel <robertwessel2@yahoo.com> - 2020-01-26 13:20 -0600
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-26 20:51 +0000
                Re: two's complement idea Robert Wessel <robertwessel2@yahoo.com> - 2020-01-26 21:02 -0600
                Re: two's complement idea Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-26 19:06 -0800
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-27 18:50 +0000
                Re: two's complement idea Robert Wessel <robertwessel2@yahoo.com> - 2020-01-27 14:18 -0600
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-27 22:13 +0100
                Re: two's complement idea Bart <bc@freeuk.com> - 2020-01-27 21:38 +0000
                Re: two's complement idea Robert Wessel <robertwessel2@yahoo.com> - 2020-01-27 19:37 -0600
                Re: two's complement idea Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-27 19:15 -0800
                Re: two's complement idea "Fred. Zwarts" <F.Zwarts@KVI.nl> - 2020-01-28 11:45 +0100
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-27 16:31 +1300
                Re: two's complement idea Manfred <noname@add.invalid> - 2020-01-26 18:50 +0100
                Re: two's complement idea Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-26 18:57 +0000
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-26 20:46 +0100
                Re: two's complement idea Robert Wessel <robertwessel2@yahoo.com> - 2020-01-26 13:14 -0600
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-26 22:15 +0100
                Re: two's complement idea Robert Wessel <robertwessel2@yahoo.com> - 2020-01-27 21:06 -0600
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-28 13:08 +0100
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-27 01:50 -0800
                Re: two's complement idea Ian Collins <ian-news@hotmail.com> - 2020-01-27 08:21 +1300
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-25 20:14 +0100
                Re: two's complement idea David Brown <david.brown@hesbynett.no> - 2020-01-25 20:12 +0100
                Re: two's complement idea Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-27 07:48 -0800
                Re: two's complement idea Bonita Montero <Bonita.Montero@gmail.com> - 2020-02-18 18:46 +0100

csiph-web