why must a NamespaceAliasDeclaration's importIdentifier not be explicitlyGlobal?

David Nolden zwabel at googlemail.com
Wed Jan 19 20:44:50 UTC 2011


2011/1/19 Milian Wolff <mail at milianw.de>:
>> The flag could be removed in setImportIdentifier. However, when you
>> sometimes set an import identifier _with_ the flag and sometimes
>> _without_, then you'll be probably doing something wrong, after all
>> the "explicitly global" should have some special meaning in your
>> language.
>
> I don't think this should be enforced, this works the same way, no:
>
> namespace foobar {}
>
> namespace asdf1 {
> using namespace foobar;
> }
>
> namespace asdf2 {
> using namespace ::foobar;
> }
>
> Here, we have once a namespace include of foobar (not global, but - since no
> local namespace called foobar exists, maps to the global foobar). And then
> below, more explitly, the import to ::foobar.
>
> What is wrong with having two declarations with differing include imports
> here?

In the first case, you might also be importing something else than
::foobar, you have to do a context-dependent look-up. In the second
case, you don't really need the lookup, but you can do it too.

In both cases you import the same thing, so IMO the importIdentifier()
should also be equal. The duchain represents the semantic after all,
and not the syntax. Also there should be no unmeaningful differences
in the duchain, else you open the door for new bugs depending on those
seemingly unmeaningful differences. The choices are: Either _always_
explicitly global, or never. I picked never.

Greetings, David




More information about the KDevelop-devel mailing list