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


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

Re: How good is your C++ knowledge?

From Paavo Helde <eesnimi@osa.pri.ee>
Newsgroups comp.lang.c++
Subject Re: How good is your C++ knowledge?
Date 2025-02-10 15:52 +0200
Organization A noiseless patient Spider
Message-ID <vod0as$17tkl$1@dont-email.me> (permalink)
References (1 earlier) <vo9e2s$fgvi$1@dont-email.me> <vob60p$qdjb$3@dont-email.me> <vocd83$14hnv$1@dont-email.me> <vocht9$157k2$1@dont-email.me> <vociol$15fqo$1@dont-email.me>

Show all headers | View raw


On 10.02.2025 12:00, Muffley@PillowHQ.org wrote:
> On Mon, 10 Feb 2025 10:46:17 +0100
> David Brown <david.brown@hesbynett.no> wibbled:
>> On 10/02/2025 09:26, Muffley@PillowHQ.org wrote:
>>> On Sun, 9 Feb 2025 16:17:13 -0500
>>> James Kuyper <jameskuyper@alumni.caltech.edu> wibbled:
>>>> On 2/9/25 00:22, Andrey Tarasevich wrote:
>>>> ....
>>>>> Remember back in the day we had that issue with a pair of `>>` being
>>>>> interpreted as a single token? So, when closing multiple levels of
>>>>> nested triangular brackets we had to separate them by spaces `> >`.
>>>>> Eventually this issue has been resolved at grammatical level, and there
>>>>> was no need to be concerned about it anymore.
>>>>
>>>> They didn't correct that by changing the grammar. They simply added a
>>>> rule that
>>>> "When parsing a template-argument-list, ... the first non-nested >> is
>>>> treated as two consecutive but distinct > tokens, the first of which is
>>>> taken as the end of the template-argument-list and completes the
>>>> template-id." (13.3p4).
>>>
>>> Which is another nice example of how the C++ syntax was never really thought
>>> through properly but is just one hack on top of another.
>>>
>>
>> It /was/ thought through properly when C++ was new.  But the language
> 
> I'm not aware of what was in the language when it was still C-with-classes,
> but operator overloading AFAIK is, if not an original feature then certainly
> a very old one, and the postfix syntax is a fugly hack.

Operator overloading predates C++ and is already present in C. In C, the 
expression `x >> 1` works both for unsigned int, unsigned long, and 
unsigned long long, and produces different opcodes and different result 
types for them. That's clear overloading.

Parsing of characters `>>` is done by the C or C++ lexer. The C lexer 
needs to look ahead (though one character only) for deciding how to 
interpret the first '>'. The C++ lexer needs to look backwards for 
deciding how to interpret the second '>'. Not so different IMO.

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


Thread

How good is your C++ knowledge? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-01-14 09:31 -0800
  Re: How good is your C++ knowledge? David Brown <david.brown@hesbynett.no> - 2025-01-14 20:25 +0100
    Re: How good is your C++ knowledge? Chris Ahlstrom <OFeem1987@teleworm.us> - 2025-01-14 15:11 -0500
  Re: How good is your C++ knowledge? Phillip <nntp@fulltermprivacy.com> - 2025-01-14 15:57 -0500
  Re: How good is your C++ knowledge? Lynn McGuire <lynnmcguire5@gmail.com> - 2025-01-15 00:13 -0600
    Re: How good is your C++ knowledge? Paavo Helde <eesnimi@osa.pri.ee> - 2025-01-15 17:51 +0200
      Re: How good is your C++ knowledge? Muttley@DastardlyHQ.org - 2025-01-15 16:37 +0000
    Re: How good is your C++ knowledge? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-01-18 07:55 -0800
    Re: How good is your C++ knowledge? Vir Campestris <vir.campestris@invalid.invalid> - 2025-01-22 11:23 +0000
      Re: How good is your C++ knowledge? Paavo Helde <eesnimi@osa.pri.ee> - 2025-01-22 16:30 +0200
  Re: How good is your C++ knowledge? Rosario19 <Ros@invalid.invalid> - 2025-01-20 13:17 +0100
    Re: How good is your C++ knowledge? Muttley@DastardlyHQ.org - 2025-01-20 16:12 +0000
  Re: How good is your C++ knowledge? Andrey Tarasevich <noone@noone.net> - 2025-02-08 21:22 -0800
    Re: How good is your C++ knowledge? James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-02-09 16:17 -0500
      Re: How good is your C++ knowledge? Muffley@PillowHQ.org - 2025-02-10 08:26 +0000
        Re: How good is your C++ knowledge? David Brown <david.brown@hesbynett.no> - 2025-02-10 10:46 +0100
          Re: How good is your C++ knowledge? Muffley@PillowHQ.org - 2025-02-10 10:00 +0000
            Re: How good is your C++ knowledge? Paavo Helde <eesnimi@osa.pri.ee> - 2025-02-10 15:52 +0200
              Re: How good is your C++ knowledge? Muffley@PillowHQ.org - 2025-02-10 14:56 +0000
                Re: How good is your C++ knowledge? Paavo Helde <eesnimi@osa.pri.ee> - 2025-02-10 17:18 +0200
                Re: How good is your C++ knowledge? Muffley@PillowHQ.org - 2025-02-10 15:53 +0000

csiph-web