Naming convention for template parameters

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jul 15 16:02:14 PDT 2013


On Tue, Jul 16, 2013 at 12:52:21AM +0200, Joseph Rushton Wakeling wrote:
> Hello all,
> 
> Quick query -- what's the preferred template variable name for a range type?
> 
> I've seen both R and Range used as options but want to confirm if there's a
> preference for one or the other.  It occurs to me that Range might potentially
> clash with some library or user-created entity.
[...]

I don't think it matters in this case, as the name would only be visible
within the scope of the template, and AFAICT would shadow any external
definitions, so you shouldn't get into trouble with it.

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) is much more
self-documenting than MyStruct(R)(R r). Template signatures aren't
included in ddoc output IIRC, so this can be an important consideration.


T

-- 
Today's society is one of specialization: as you grow, you learn more and more about less and less. Eventually, you know everything about nothing.


More information about the Digitalmars-d-learn mailing list