J
James Kanze
Le vendredi 18 avril 2014 23:47:57 UTC+1, Peter a écrit :
But there's nothing in the operators which is context sensitive,
or at least, which can't be simply resolved. The real issues
are declaration syntax.
One of the big issues is template parameters and arguments; the
fact that < and > were used does lead to a number of ambiguities
(and more than one person did suggest new tokens, although
without using any new characters). You'd want some sort of
tokens with an open/close pairing, but "($" and "$)", for
example, would have made life a lot simpler. For that matter,
postfixing (or prefixing) a symbol with a "$" to indicate that
it is dependent would be a lot better than the current system,
with a lot of complicated rules that you have to second guess,
and which are difficult to explain to beginners.
One of the problems with $, of course, is that it is a frequent
extension to accept it in symbols.
I didn't mean to invent a new operator, I just wondered
why none of the two symbols mentioned by me were used
to denote one of already existing operators.
C and C++ are known for being context sensitive which
is one of the reasons why it's so hard to write a compiler
for them.
But there's nothing in the operators which is context sensitive,
or at least, which can't be simply resolved. The real issues
are declaration syntax.
With two extra symbols this context
sensitivity could at least have been reduced.
Example: & currently means three different things
in C++: a reference, an "address of" operator and "bit and".
If there were two symbols left, why weren't they used
by language creators to reduce some of this ambiguity
in favor of simpler grammar? An "address of" operator
could be, for example, @ (as someone noticed, it is
in Pascal). Perhaps $ could have been used to represent
a C++11 rvalue reference. Instead it was decided to reuse
the good old &&.
One of the big issues is template parameters and arguments; the
fact that < and > were used does lead to a number of ambiguities
(and more than one person did suggest new tokens, although
without using any new characters). You'd want some sort of
tokens with an open/close pairing, but "($" and "$)", for
example, would have made life a lot simpler. For that matter,
postfixing (or prefixing) a symbol with a "$" to indicate that
it is dependent would be a lot better than the current system,
with a lot of complicated rules that you have to second guess,
and which are difficult to explain to beginners.
One of the problems with $, of course, is that it is a frequent
extension to accept it in symbols.