small idea

monarch_dodra monarchdodra at gmail.com
Wed Jan 9 07:57:21 PST 2013


On Wednesday, 9 January 2013 at 14:28:32 UTC, eles wrote:
> In D, this is signalled by the in/out/inout keywords.

Just FYI: This may not be accurate.

For starters, inout has *nothing* to do with in or out. It is 
used as a wild qualifier: 
http://dlang.org/function.html#Inout_Functions

"in" means not only that you will read the variable, but that it 
will be both const and scope. const is *very* restrictive in D.

"out" parameters are first init initialized. This means that if 
you want to pass a parameter, that the function is supposed to 
modify, but not necessarily read (such as an appender), then 
"out" won't work (it will clobber your out parameter first).

So the "general" case where you pass something by value, but 
mutate it (for example, passing range), then neither "in" nor 
"out" will work (nor "inout").



More information about the Digitalmars-d mailing list