import concerns (was Re: Historical language survey)
Sean Kelly
sean at f4.ca
Sat Jul 8 08:45:58 PDT 2006
Sean Kelly wrote:
> Walter Bright wrote:
>> Derek Parnell wrote:
>>> On Sat, 08 Jul 2006 06:56:47 +1000, Walter Bright
>>> <newshound at digitalmars.com> wrote:
>>>
>>>> The alias works at any level you choose to make it. Alias can be
>>>> used to 'import' any name into the current namespace, making it
>>>> first class.
>>>
>>> Even names that are declared 'private' in the imported module? Is
>>> that how you want it to work Walter? If so, why do we bother with
>>> 'private'? What's the point?
>>
>> In class scope, access control is done *after* name lookup, not
>> before. I'm concerned about confusion by reversing the order of that
>> for module scope.
>
> In D though, 'private' always implies module visibility, whether it it
> at module scope or class scope. If the behavior at module scope is
> changed, would it affect its behavior at class scope as well?
By the way, if private were changed at both module and class level,
which I do think makes sense on some levels, this behavior would change:
module main;
class C
{
private:
void fn() { printf( "C\n" ); }
}
void fn() { printf( "glob\n" ); }
class D : C
{
void go() { fn(); }
}
void main()
{
D d = new D;
d.go;
}
Currently, this prints "C". But if privates were truly private then I
would expect it to either print "glob" or to get a compile error that
two matching function were found and that D's call to 'fn' must be
qualified by either prefixing it with a '.' or 'C.' to indicate intent.
Sean
More information about the Digitalmars-d
mailing list