User:WebDrake/Template parameter standard names

From D Wiki
Jump to: navigation, search

This table is an attempt to create a standardized list of recommended template parameter names for use in D. Names are chosen to try and provide an optimal balance between ease of typing and ease of later understanding.

Use numerical labels for multiple similar parameters, e.g. T1, T2, ... Range1, Range2, ... etc., or alternatively annotations that give info about their purpose: e.g. SourceRange, TargetRange.

Parameter Name Notes
Arbitrary type T As typical for C++. Note Value has also been used in Phobos.
Arguments args Seems to be typical, but why not Args?
Array A e.g. foo(A : T[], T)(A arr)
Character type C Could also use Char ... ?
Element of a range E e.g. foo(Range, E)(Range r, E e) — perhaps use Element instead? Or just T?
Function alias fun
Predicate alias pred
Range Range Use R internally as an alias: e.g. alias Unqual!Range R. Can be annotated if specific range constraints are needed, e.g. ForwardRange, BidirectionalRange, but this is not obligatory.
Separator Separator as in e.g. std.algorithm.splitter, joiner
String type String
Uniform random number generator UniformRNG Could also use RandGen, but less specific.