help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %prefix with C++ namespaces


From: Vincent Zweije
Subject: Re: %prefix with C++ namespaces
Date: Tue, 02 Oct 2007 10:19:40 +0200
User-agent: Icedove 1.5.0.10 (X11/20070329)

Sebastian Pipping wrote:
Joel E. Denny wrote:
I figured the namespace name is meant to be relative to the global namespace, so a leading "::" is implicit if not specified.
I'm not sure if this is true. Could it be that without "::"
it's relative to the namespace the call was made from instead
of the global namespace?

I assume so because I had lex() in its own namespace and yylex
defined to "lex" working together before.
That is the case.
The leading part of the name (eg foo in foo::bar::baz) is looked up using the usual lookup rules for plain identifers. The search starts in the scope where it's used, and in subsequently enclosing namespaces counting from the place where it's used, ultimately leading to the global namespace if it's not found anywhere else. When the leading part is found to be a namespace, the next part (bar) is looked up in that. The actual workings of qualified name lookup in C++ are pretty complicated, especially when you start considering classes and using declarations. Read section 3.4 "Name lookup" [basic.lookup] of the C++ standard for details.

Ciao.
Vincent.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]