Implicit template properties
Stewart Gordon
smjg_1998 at yahoo.com
Sat Mar 10 10:44:15 PST 2007
Sean Kelly Wrote:
> Frits van Bommel wrote:
<snip>
>> [1]: I'm not sure if private template members are accessible
>> from the rest of the module they're declared in, like class &
>> struct members. If they are, that might screw things up.
>
> A possible alternative that I think has been proposed before
> would be to overload the meaning of 'this' for this purpose.
> Then the rule could be "If a template has exactly one member
> in it, and the name of that member is the same, or if a
> template contains a 'this' member..."
The problem is that the potential ambiguity remains. Given this
template Qwert(T) {
class this {
static int yuiop;
}
int yuiop;
}
Now, is Qwert!(int).yuiop the member of the class or of the template? Requiring the other members to be private wouldn't do it, because
(a) the class will most likely need to be able to distinguish between them
(b) private members are still accessible within the module (though adding a 'veryprivate' attribute that stops this would deal with this)
You could try adding a rule that no member of the implicit template member may have the same name as a member of the template. But an ambiguity still remains: you can create aliases of template instances. This ambiguity doesn't happen with the existing implicit member, because in the cases where it applies, the template instance and the implicit member thereof are one and the same thing.
Stewart.
More information about the Digitalmars-d
mailing list