| convention | what it means/when to use | |-------------------------+-------------------------------------------| | V v | V is primitive, dynamic arr, assoc array, | | | COW, or kown copy cheap (< 16 bytes) | | | | | const(V) v | same as (V v), pedantic - makes copy and | | | guarantees no mutation in function | | | | | immutable(V) v | No need - for ensuring no local changes | | | prefer 'const(V) v' | | | | | ref V v | Use only when mutation of v is required | | | | | ref const(V) v | Indicate v will not be changed, accepts | | | {V, const(V), immutable(V)} | | | | | ref immutable(V) v | No need - restrictive with no benefit | | | over 'ref const(V) v' | | | | | V* v | Use only when mutation of v is required. | | | Prefer 'ref V v' unless null significant | | | or unsafe manipulations desired | | | | | const(V)* v | Indicate v will not be changed, | | | accepts {V*, const(V)*, immutable(V)*} | | | still prefer ref unless null significant | | | or unsafe manipulations desired | | | | | immutable(V)* v | No need - restrictive with no benefit | | | over 'const(V)* v' | | | | | T t | T is primitive, dynamic array, or assoc | | | array (i.e. cheap/shallow copies). For | | | generic code no knowledge of COW or | | | cheapness so prefer 'ref T t' | | | | | const(T) t | same as (T t), pedantic - makes copy and | | | guarantees no mutation in function | | | | | immutable(T) t | No need - for ensuring no local changes | | | prefer 'const(V) v' | | | | | ref T t | Use only when mutation of t is required | | | prefer 'ref const(T) t' if mutation not | | | required | | | | | ref const(T) t | Indicate t will not be changed, accepts | | | {T, const(T), immutable(T)} without copy | | | | | ref immutable(T) t | No need - restrictive with no benefit | | | over 'ref const(T) t' | | | | | auto ref T t | Use only when mutation of t required and | | | want support of by value for rvalues | | | (May be obviated in the long run) | | | | | auto ref const(T) t | Indicate t will not be changed, accepts | | | [lr]value {T, const(T), immutable(T)} | | | (May be obviated in the long run) | | | | | auto ref immutable(T) t | No need - restrictive with no benefit | | | over 'auto ref const(T) t' | | | | | T* t | Use only when mutation of t is required. | | | Prefer 'ref T t' unless null is | | | significant or dealing with unsafe code. | | | | | const(T)* t | Prefer 'ref const(T) t' unless | | | null is significant or dealing with | | | unsafe code | | | | | immutable(T)* t | No need - restrictive with no benefit | | | over 'const(T)* t' | | | |