Naming convention for template parameters

Meta jared771 at gmail.com
Mon Jul 15 19:23:32 PDT 2013


On Monday, 15 July 2013 at 23:03:45 UTC, H. S. Teoh wrote:
> I generally use R 'cos it's less typing and I'm lazy, but 
> Walter has
> been recently of the opinion that a more descriptive name is 
> necessary
> for ddoc purposes, e.g., MyStruct(InputRange)(InputRange r)

One thing about that is that the type is being encoded into the 
name of the template parameter. Ideally, the type shouldn't be 
important, with the template constraints documenting anything 
noteworthy. With MyStruct, for example, I think 
MyStruct(Range)(Range r) would be better than the former, as it's 
more general. Then a template constraint such as 
if(isInputRange!Range) documents that the type must be at least 
an input range.


More information about the Digitalmars-d-learn mailing list