Func Param Confusion - in/out/inout/ref/const/immutable

Zane zane.sims at gmail.com
Fri Feb 22 11:19:49 PST 2013


When is it appropriate to use in, out, inout, ref, immutable, and 
const in function parameters? I read the documentation and 
understand the basics behind them, but I'm a little confused, for 
example, why someone would want to use 'out' instead of 'ref', 
why 'in' instead of 'const', or why 'immutable' instead of 
'const'? If 'inout' is used as a wildcard, allowing for any of 
several storage classes, why is it needed at all (wouldn't 'ref' 
work?). The more I think I get it, the more I end up getting 
confused. Am I thinking about this too hard? FYI: I come from 
primarily a C/Java/PHP background, so these concepts are 
relatively new to me - it feels excessive, though I am willing to 
learn.


More information about the Digitalmars-d-learn mailing list