help-bison
[Top][All Lists]
Advanced

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

Re: %prefix with C++ namespaces


From: Hans Aberg
Subject: Re: %prefix with C++ namespaces
Date: Tue, 2 Oct 2007 11:01:11 +0200

On 2 Oct 2007, at 07:03, Joel E. Denny wrote:

It also occurs to me now that a leading "::" is not completely redundant.
The given namespace is used in two ways: for declarations and for
references. The former needs the splitting we discussed. I think the latter would use the given namespace unaltered. In that case, the leading
"::" would reference the global namespace absolutely.

Perhaps you missed it, but in another post, I compared C++ "::" to the "/" of UNIX filepaths. When it starts with "::", it is like a UNIX absolute or full
path; otherwise, it is a relative path.

No, I get the analogy.  Did I say something to contradict it?

No. We say the same, I think. :-)

I'm having trouble
imagining important scenarios where this will actually help disambiguate a reference. However, the C++ compiler would complain in the scenario you
describe.

As for using a leading "::" for reference, I think that is admitted - or is my
memory failing me? :-)

It's allowed.  My point is that, if the user has wrapped parser.cc in
another namespace, the compiler will complain about any use of the
absolute reference because it won't include that outer namespace.

Yes, if there are absolute references. I was only thinking about the nested 'namespace ...' wrapping, where the innermost names do not contain "::". But if these names are references by a full path somewhere, the compiler will generate an error.

In any case, I just tried wrapping parser.cc in a namespace, and it looks like there are many other compilation problems the user would have to work
around anyway, so this issue is probably moot.

Yes, I think
  namespace <name> { ... #include "parser.cc" ... }
invites problems. So that something not to be officially supported by Bison, I suspect. :-)

I do not think the leading "::"-issue is very important - but it would be nice
showing one has given thought to it. :-)

So, I'm seeing no reason to disallow it.  If the user wants absolute
references, he should probably get absolute references.

It is OK with me whatever you do. Admitting a leading "::", and merely stripping it out in the "namespace" nesting seems fine. It seems reasonable enough that more special uses could be considered later, if somebody has an input. :-)

  Hans Aberg






reply via email to

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