Topic: Leading [ in expressions and declarations
Author: qg4h9ykc5m@yahoo.com (David Olsen)
Date: Mon, 29 Nov 2004 21:33:16 GMT Raw View
Davide Bolcioni wrote:
> in the thread 'c++ wishlist', back in September, it was repeatedly
> asserted that no legal C++ expression can begin with a leading [.
>
> Assuming this is indeed the case, I am now wondering: is this also
> true for declarations ?
Yes. A declaration cannot start with a [ token.
(The following is from memory, so the details may not be quite correct.
But I'm pretty sure that it is generally correct.)
A declaration consists of a decl-spec and one or more declarators.
A decl-spec can only contain a [ token if the [ token is within a
class/struct/union/enum definition or within template arguments. In
both cases, it can't be at the beginning of the decl-spec.
A declarator can begin with a [ token, so we need to consider the case
where the decl-spec is empty, which means the declaration starts with
the declarator. But (if I remember correctly) a decl-spec can only be
empty for declarations of constructors, destructors, and type conversion
operators. And in those limited cases, the declarator must begin with a
qualified name (for out-of-class definitions) or with an identifier, ~
token, or operator keyword respectively (for in-class declarations). So
a declarator that is preceded by an empty decl-spec cannot begin with a
[ token.
Therefore, a legal C++ declaration cannot start with a [ token.
--
David Olsen
qg4h9ykc5m@yahoo.com
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]
Author: f5xz2bk02@sneakemail.com (Davide Bolcioni)
Date: Wed, 24 Nov 2004 00:22:10 GMT Raw View
Greetings,
in the thread 'c++ wishlist', back in September, it was repeatedly
asserted that no legal C++ expression can begin with a leading [.
Assuming this is indeed the case, I am now wondering: is this also
true for declarations ?
Thank you for your consideration,
Davide Bolcioni
--
Paranoia is an afterthought.
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]