Should alias expand visibility?

Pelle pelle.mansson at gmail.com
Tue Jul 27 13:19:59 PDT 2010


On 07/27/2010 08:30 PM, Tomek Sowiński wrote:
> Pelle wrote:
>
>> On 07/26/2010 12:23 AM, Tomek Sowiński wrote:
>>> If foo is private but its public alias poo exists, should you be able to
>>> use poo? (currently you can't)
>>>
>>>
>>> Tomek
>>
>> I think you should, because of this:
>>
>> private import package;
>>
>> alias package.function myFun;
>>
>> If you want to provide a function from a package but not forward the
>> visibility of the entire package.
>
> Not exactly what I had in mind. function in package must be declared as
> public to be able to import it so the alias is not expanding its visibility.
> See other posts for relevant examples.
>

But if I do a private import, I do not extend the visibility of that 
package beyond my current file. I want to extend the visibility of just 
one of the imported functions. Like this, for example:

In file a:

private import std.stdio;
public alias std.stdio.writeln print;

In file b:

import a;
print("Hello!");


.. Heh.
This seems to work already. I probably should have tried before I posted :)

I see no reason not to extend this to class level, though.


More information about the Digitalmars-d mailing list