On Tuesday, 5 July 2016 at 19:00:14 UTC, Tofu Ninja wrote:
On Tuesday, 5 July 2016 at 18:48:05 UTC, Tofu Ninja wrote:
Also there could be code re-use wherever the access rights
match. So if an argument is marked as opt-in, only the
instantiation scope's access to that argument would need to be
tied to the template instantiation. I suppose that means there
would be 4 possible instantiations, one for private, package,
protected, and public access.
Actually scratch that, it would have to match on access rights
to the argument and any symbol accessible through the argument.
It would get even crazier on recursive instantiations, so I
think you are right, the template would have to be tied to the
original instantiation module. If the template instantiated any
other templates that had this behavior it would also have to be
tied to the original module. Sounds complicated.
Using mixin templates you can get the behavior you want to some
extent, with exception that you need to type "mixin" in front
when you're instantiating them.
I wonder if reusing the mixin statement for normal templates
would be a good idea to reuse existing code while allowing access
to private members.