There are comparatively many storage class specifiers for functions arguments in D, which are:
- none
in(which is equivalent toconst scope)outrefscopelazyconstimmutablesharedinout
What's the rational behind them? Their names already put forth the obvious use. However, there are some open questions:
- Should I use
refcombined withinforstructtype function arguments by default? - Does
outimplyrefimplicitely? - When should I use none?
- Does
refon classes and/or interfaces make sense? (Class types are references by default.) - How about
refon array slices? - Should I use
constfor built-in arithmetic types, whenever possible?
More generally put: When and why should I use which storage class specifier for function argument types in case of built-in types, arrays, structs, classes and interfaces?
(In order to isolate the scope of the question a little bit, please don't discuss shared, since it has its own isolated meaning.)