Topic: Operators and punctuators.


Author: James Kuyper <kuyper@wizard.net>
Date: 1999/12/13
Raw View
Bill Wade wrote:
>
> James Kuyper Jr. wrote in message <384E6890.B3C35D0C@wizard.net>...
> >
> >The only definition of an operator in the standard is in 13.5 p1:
>
> To add to the confusion, 5.4/2 talks about "... type conversion operator
> (dynamic_cast, ..."

I referred to that, indirectly:

> > Some operators such as sizeof and static_cast also shouldn't be
> > included, since they are already covered by the _keyword_ entry;

The new, delete, const_cast, and dynamic_cast operators are also in that
category.

To add to the confusion, I've checked the C standard for comparison, and
it defines the term "punctuator" to include all of the operators that
are not also keywords.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: wmm@fastdial.net
Date: 1999/12/14
Raw View
In article <384E6890.B3C35D0C@wizard.net>,
  "James Kuyper Jr." <kuyper@wizard.net> wrote:
>
> Should I file a defect report over this? It really amounts to little
> more than a clarification. However, as it currently stand the standard
> leaves _punctuator_ undefined. To get what I think were the intended
> effects without changing the current definition of _operator_, the
> missing definition of _punctuator_ would have to include the ? and :
> tokens, plus the ::, ., and .* operators, which seems counter-
intuitive.

I think this is a valid criticism, and I'll be adding it to the
core language issues list.
--
William M. Miller, wmm@fastdial.net
OnDisplay, Inc. (www.ondisplay.com)


Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Bill Wade" <bill.wade@stoner.com>
Date: 1999/12/13
Raw View

James Kuyper Jr. wrote in message <384E6890.B3C35D0C@wizard.net>...
>
>The only definition of an operator in the standard is in 13.5 p1:

To add to the confusion, 5.4/2 talks about "... type conversion operator
(dynamic_cast, ..."





[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: 1999/12/08
Raw View
The only definition of an operator in the standard is in 13.5 p1:

_operator_: one of
        new delete    new[]      delete[]
        +   -    *    /    %     ^    &    |    ~
        !   =    <    >    +=    -=   *=   /=   %=
        ^=  &=   |=   <<   >>    >>=  <<=  ==   !=
        <=  >=   &&   ||   ++    --   ,    ->*  ->
        ()  []

However, that doesn't seem to be a complete list of operators, but only
of the operators that can be overloaded. Section 2.6 p1 defines:

_token_:
        _identifier_
        _keyword_
        _literal_
        _operator_
        _punctuator_

But there doesn't appear to be any comprehensive definition of
_operator_ except the one in 13.5 p1, and none at all for _punctuator_.
Section 2.12 defines _preprocessing-op-or-punc_, but doesn't distinguish
between operators and punctuators. In any event, _preprocessing-op-punc_
is used for defining _preprocessing-token_ in section 2.14; it's not
meant for defining _token_. The following entries from 2.12 are not in
13.5:

punctuators?
        {       }       ;       ...

Operators only when found inside a macro expansion (section 16.3.2,
16.3.3). Otherwise, they're punctuators?
        #       ##

alternative tokens, which are alternative spellings for other operators
(section 2.5):
        <:      :>      <%      %>      %:      %:%:    and
        and_eq  bitand  bitor   compl   not     not_eq  or
        or_eq   xor     xor_eq

operators that are explicitly not overloadable (13.5.1 p3):
        ?:      ::      .       .*

Note: ?: is not defined as a _preprocessing-op-or-punc_ in 2.12.
Instead, ? and : are each listed separately.

I'd like to suggest that:
1. Section 13.5 p1 be changed to define and use _overloadable-operator_,
rather than _operator_, since it doesn't include the operators that
can't be overloaded.

2. Section 2.6 be changed to refer to _operator-token_ instead of
_operator_, since it shouldn't include the preprocessing operators that
aren't tokens, and ?: should be parsed as two separate tokens.
Some operators such as sizeof and static_cast also shouldn't be
included, since they are already covered by the _keyword_ entry; it
would be confusing to have _token_ defined in terms of overlapping
sub-categories. They'd be operators that were also tokens, yet not
operator-tokens. That would no more confusing than having null pointer
constants which are necessarily not pointers. Still, maybe there's a
better name for the category.

3. Two new subsections should be added to section 2, defining
_operator-token_ and _punctuator_, for cross-reference from section 2.6.
Alternatively, those sections could be combined, as were the
corresponding ones for _preprocessing-token_. The definition of
_operator-token_ should not include #, ##, or ?:, and should include ?
and : separately.

Should I file a defect report over this? It really amounts to little
more than a clarification. However, as it currently stand the standard
leaves _punctuator_ undefined. To get what I think were the intended
effects without changing the current definition of _operator_, the
missing definition of _punctuator_ would have to include the ? and :
tokens, plus the ::, ., and .* operators, which seems counter-intuitive.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]