Parallel Merge Sort

anonymous via Digitalmars-d digitalmars-d at
Tue Mar 3 18:05:45 PST 2015

On Wednesday, 4 March 2015 at 01:17:00 UTC, H. S. Teoh wrote:
> The 'in' modifier is the same as 'const' when applied to 
> function
> parameters, but writing 'in' documents that the parameters are 
> input
> parameters that won't be modified by the function.

You forgot to mention "scope". "in" is short for "scope const". 
'scope' means that the argument is used only in this run of the 
function; it's not stored anywhere (a global, a struct/class 
member, ...).

> (Conversely, writing
> 'out' documents that the parameter is an output parameter: the 
> compiler
> initializes it to its default state, and the function 
> (presumably)
> stores its output value(s) in that parameter before returning.
> Semantically, 'out' is the same as mutable, which is unmarked 
> in D. But
> writing 'out' helps code maintainability by documenting the 
> intent of
> function parameters, so that readers of your code don't have to 
> guess
> what the purpose of the parameter might be and how it should be 
> used.)

You forgot to mention that "out" parameters work like "ref" 
parameters (plus resetting to default value). That is, arguments 
are passed by reference; changes that the function makes affect 
the given lvalue at the call site.

More information about the Digitalmars-d mailing list