C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] (SC22WG14.19272) adding punctuator tokens

From: Aaron Ballman <aaron_at_[hidden]>
Date: Thu, 15 Apr 2021 08:41:34 -0400
On Thu, Apr 15, 2021 at 8:02 AM Jens Gustedt <jens.gustedt_at_[hidden]> wrote:
>
> Aaron,
>
> on Thu, 15 Apr 2021 07:08:34 -0400 you (Aaron Ballman
> <aaron_at_[hidden]>) wrote:
>
> > On Thu, Apr 15, 2021 at 6:50 AM Jens Gustedt via Liaison
> > <liaison_at_[hidden]> wrote:
> > >
> > > Ville,
> > >
> > > on Thu, 15 Apr 2021 13:22:05 +0300 you (Ville Voutilainen
> > > <ville.voutilainen_at_[hidden]>) wrote:
> > ...
>
> > > no, these operators are not new, they would just be different
> > > spellings
> > >
> > > (and I described how I see that this fits into the C specification
> > > in several papers, you could have a look at
> > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2644.pdf, for
> > > example)
> > > > and add them as alternative spellings of some existing semantic
> > > > descriptions. Overall, I think there's not much specification
> > > > difficulty, at least not for things that are just alternate
> > > > spellings.
> > >
> > > That's the kind of information that I was after, thank you.
> > >
> > > > I don't know whether you envision adding new operators,
> > >
> > > no
> >
> > Then these aren't "just different spellings" as far as I can tell. For
> > example, this is valid C++ code that uses a different spelling:
> >
> > struct S {
> > int operator and(int i); // [lex.digraph]
> > int operator <::>(int i) const; // [lex.digraph]
> > };
>
> yes
>
> > Why are these hypothetical punctuators different?
>
> Sorry, maybe I don't get what you are asking.

Perhaps I misunderstood, but I thought Ville was asking whether you'd
be able to write:

int operator∧(int i);

and I thought you were answering that you did not intend for that to
be a valid operator overload.

> If you'd have `¬a ∧ b` that would just be another spelling of `!a && b`.
>
> If you'd have `⟦vendor∷pride⟧` that would effectively be two new
> tokens `⟦` and `⟧` that the languages do not yet have, compared to the
> one token `∷` that would be another spelling of `::`. We would have to
> have a syntax rule to make this equivalent to `[[vendor::pride]]`.
>
> But these tokens would not be operator tokens with new semantic or so,
> just new syntactic notation of some part of a declarator.

My concern is addressed if operator ∧(), operator &&(), and operator
and() are all identical declarations (except for spelling). e.g., I
should be able to write:

struct S {
  int operator∧(int) const;
};

S s;
s && 12; // ok, calls operator∧()

~Aaron


>
> Jens
>
> --
> :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
> :: ::::::::::::::: office Strasbourg : +33 368854536 ::
> :: :::::::::::::::::::::: gsm France : +33 651400183 ::
> :: ::::::::::::::: gsm international : +49 15737185122 ::
> :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2021-04-15 07:41:53