On 5/4/23 7:38 AM, David Brown via Std-Proposals wrote:
On 04/05/2023 11:47, Timur Doumler via Std-Proposals wrote:
I don't think we could ever have operator** because ** has a meaning
in C++ today (multiplication followed by dereference, or double
dereference). Am I missing something?

Cheers, Timur


Yes, "x ** y" currently parses as "x * (*y)".  I don't know how that could be resolved without making spaces more significant in token parsing.

(Personally, I'd be happy to see the introduction of rules regulating spacing in connection with operators - it would lead to neater, more consistent code that is easier for mere humans to read.  But the standards committee have their little obsessions about backwards compatibility of existing code, so I don't think that would be accepted!)


If only C++ allowed Unicode symbols and punctuation as identifier letters, we could use "x ↑ y" for exponentiation (and annoy programmers with limited keyboard layouts!).

The draft C23 and C++23 standards both follow Unicode UAX #31 recommendations for characters allowed in identifiers (see N2836 for C and P1949 for C++). The Unicode standard also provides a specification of characters that are suitable for use as operators. Swift relies on such Unicode properties to allow user-defined custom operators. There is no technical reason that C++ can't do similarly, but no such proposal has been published at this time.

Tom.



David