On 7/7/16 7:49 AM, Tofu Ninja wrote:
On Friday, 1 July 2016 at 19:13:45 UTC, Steven Schveighoffer wrote:
Emplace needs a constructor alias parameter.

-Steve

That wouldn't work as emplace wouldn't be able to use the alias if it
was private...

void main(){
     import other;
     test!foo();
}

private void foo(){}
##########
module other;
void test(alias pred)(){
    pred();
}



other.d(5): Error: function main.foo is not accessible from module other
main.d(9): Error: template instance other.test!(foo) error instantiating

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

Reply via email to