[Synopsis-devel] Re: Synopsis Question
Stefan Seefeld seefeld at sympatico.caMon Aug 15 10:39:34 UTC 2005
- Previous message: [Synopsis-devel] Re: Synopsis Question
- Next message: [Synopsis-devel] Re: Synopsis Question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Luke Petre wrote:
>> Thanks for looking into this ! Does the file compile if you simply
>> replace '::callback' by 'callback' everywhere, i.e. don't qualify
>> 'callback' any more ?
>>
>
> Yes. The only line that really matters is in the sighandler function.
> The reference in the constructor of ErrorHandler compiles either way.
> My 2c is that while you're in the anonymous namespace, the '::' is
> forcing the compiler to only consider symbols outside of the current
> namespace. Or something strange like that.
Right. Unfortunately I don't remember why I introduced the qualification
in the first place. I'v removed it now, so everything should work fine.
>> That's right, but that defeats the purpose of the anonymous namespace to
>> deliberately hide the symbols it declares from the outside.
>>
>
> Hrm. If I follow what you're saying, the use of anonymous namespaces
> here is to prevent something like this:
>
> // file.cc
> namespace Synopsis
> {
> extern ErrorHandler::Callback callback;
> }
>
> void foo()
> {
> if ( Synopsis::callback ) Synopsis::callback();
> }
>
> I guess I've never really thought about enforcing restricted access like
> that. Pretty cool.
Exactly. It is the equivalent of C's 'static'.
Regards,
Stefan
- Previous message: [Synopsis-devel] Re: Synopsis Question
- Next message: [Synopsis-devel] Re: Synopsis Question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-devel mailing list