Logical location of template instantiations
Tofu Ninja via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 7 06:58:38 PDT 2016
On Thursday, 7 July 2016 at 12:39:51 UTC, Steven Schveighoffer
wrote:
> Yes, it is a problem. I still don't understand how the
> *calling* of a private function is the problem, vs. the
> aliasing of it. Why aren't we preventing the aliasing of the
> private function in the first place (if not allowed)? If you
> can get an alias, you should be able to call it.
>
> I understand that aliases are strange in this way. What we
> really need is an alias to the protection level. An explicit
> permission given to an external template that says "for this
> one instantiation, you can pretend you have access to this".
>
> A workaround, of course, is to use a delegate.
>
> I came across this when learning vibe.d, which gets around the
> requirement in an interesting way:
> https://github.com/rejectedsoftware/vibe.d/issues/1516
>
> -Steve
It makes sense that the aliasing a private member works, when it
is made at the instantiation site it is perfectly visible. It
only gets mucked up when the alias travels out of that context
into the template where it is no longer visible.
More information about the Digitalmars-d
mailing list