Implicit template properties

Sean Kelly sean at f4.ca
Sat Mar 10 09:10:52 PST 2007


Frits van Bommel wrote:
> Neal Becker wrote:
>> I'm reading D specification, and I found:
>> "If a template has exactly one member in it, and the name of that 
>> member is
>> the same...".
>>
>> That strikes me as strange.  It seems reasonable to use the name as a
>> trigger for the Implicit template property feature, but what is the 
>> reason
>> for the restriction to 'exactly one member'?
> 
> Because the other names otherwise wouldn't be (externally) accessible 
> any more, I guess.
> Though that reason only applies when the others aren't private[1], which 
> is why there have been suggestions to change this rule to "one _public_ 
> member" instead of "one member"...
> 
> 
> [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..."


Sean



More information about the Digitalmars-d mailing list