Should alias expand visibility?

Steven Schveighoffer schveiguy at yahoo.com
Tue Jul 27 13:39:10 PDT 2010


On Tue, 27 Jul 2010 14:42:12 -0400, Tomek Sowiński <just at ask.me> wrote:

> Steven Schveighoffer wrote:
>
>> I think the better argument is that it serves
>> no purpose to have a private alias to a public function.  You can just  
>> as
>> easily call the public function.
>
> private alias ClassFromModuleBeyondReach.awkwardStaticName awkwardHelper;

This is a good point.  But we are talking about aliasing a private  
function into a public one.  Which means both must be defined in the same  
module.  Which means the symbol being aliased is not beyond reach, and is  
probably pretty easy to call.

But let's expand on this.  Let's assume I have:

private void funcA() {}
public alias funcA funcB;

How is this different than:

public void funcB() {}
private alias funcB funcA;

It doesn't lend itself well to your example of byColumn and byRows,  
because you want to define the private function.  The problem really comes  
down to the fact that you can't make a static decision for the name of the  
function, because then you have to repeat the whole function.

But I'm not sure how easy it would be to implement.  I also note from some  
experimentation that aliasing member variables doesn't work?  That should  
probably be fixed.

The "issue" of having a private function have to be declared public is not  
a huge one though.  I don't see this being convincing enough to Walter,  
but maybe he would consider it.  It's definitely worth putting into  
bugzilla.

-Steve


More information about the Digitalmars-d mailing list