Should alias expand visibility?
Tomek Sowiński
just at ask.me
Tue Jul 27 14:16:57 PDT 2010
Steven Schveighoffer wrote:
> 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.
You said "private alias to a public function", look above ;)
> 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;
Now import funcB from another module. It fails. If such an alias is wrong
(not completely sure) then the compiler should flag it already where it's
declared.
> How is this different than:
>
> public void funcB() {}
> private alias funcB funcA;
Because this always works (can use the alias) and the above doesn't.
> 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.
Yeah, but what? That visibility expanding aliases should be useable or that
the compiler should ban such declarations? I'm veering towards banning
because of alias-presence-may-alter-generated-code issue I mentioned in the
other post.
Tomek
More information about the Digitalmars-d
mailing list