Re: throw operator
On 2007-10-04 21:28, Kai-Uwe Bux wrote:
James Kanze wrote:
On Oct 4, 8:05 am, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
Ranganath wrote:
On Oct 3, 8:46 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
Ranganath wrote:
Why is throw keyword considered as an operator?
It is impossible to answer a question based on a wrong premise.
'throw' is not an operator. Why do you think it is one? Or,
rather, what do you mean "considered as an operator"? What is
the context?
throw is an operator.
According to the language standard, "throw" is a keyword, not an
operator.
As far as I can see, the language standard doesn't define
operators. Without a definition, I'm incapable of saying
whether throw is an operator or not.
Well: Yes and No. I agree that operator is not put in italics anywhere in
the standard. However, the word "operator" is clearly used in the standard
in many places refering to things like "+". But nowhere in the standard
is "throw" referred to as an operator. Also, there are certain classes of
operators that are defined in the standard (like unary operators,
multiplicative operators, or overloadable operators) and throw is not a
member in any of those.
As for the table in [2.12]: as far as I know, there is no place where the
standard refers to anything as an operator that is not listed in [2.12].
This way, the standard establishes a somewhat consistent pattern of usage
for the word "operator". It is consistent with this pattern to say
that "throw" is not an operator and somewhat inconsistent to say it is.
On the other hand the second sentence in section 5 (Expressions) reads
"An expression is a sequence of operators and operands that specifies a
computation." (Though this sentence is part of a note, so IIRC it should
not be normative.) And the second sentence in section 15 (Exceptions) is
"A handler will be invoked only by a /throw-expression/ ..." Lastly in
section 15.1, the third paragraph begins with "A /throw-expression/ a
temporary object, the type of which is determined by removing any top
level /cv-qualifiers/ from the static type of the operand of throw..."
So, expressions consists of operators and operands, and there exists
throw-expressions which are on the form of 'throw foo();' where foo is
an operand, which more or less means that throw should be a operator,
provided that the first sentence I quoted applies.
--
Erik Wikstr??m