And what will we do about package?

Mike Parker aldacron at gmail.com
Sat Nov 21 04:46:46 PST 2009


Don wrote:
> Vladimir Panteleev wrote:
>> On Fri, 20 Nov 2009 18:52:09 +0200, Don <nospam at nospam.com> wrote:
>>
>>> module first.second.third.fourth;
>>>  which package is this module part of?
>>> Is it 'third', 'second.third', or 'first.second.third'?
>>
>> Perhaps you meant: 'first', 'first.second', or 'first.second.third'?
> 
> 
>>
>> The case you mention presents an immediate ambiguity, but it is 
>> clarified by the module declaration or on the first import. If 
>> 'first.second.foo' imports 'first.second.third.bar' by 'import 
>> third.bar', and 'first.second.third.bar' has a module declaration or 
>> is imported from somewhere else using a different package "path", the 
>> compiler will generate an error ("Error: module X is in multiple 
>> packages Y")
> 
> How do you define module fourth so that its 'package' functions are 
> accesssable only to modules in first.second.* and not in first.* ?
> 

You don't. The package in this case should be first.second.third and 
that's that. That's how it works in Java and is sometimes quite useful.



More information about the Digitalmars-d mailing list