So what does (inout int = 0) do?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 14 20:10:12 PDT 2016


Consider:

https://github.com/D-Programming-Language/phobos/blob/master/std/range/primitives.d#L152

There is no explanation to it in the source code, and the line blames to 
https://github.com/D-Programming-Language/phobos/pull/2661 (irrelevant).

Commenting it out yields a number of unittest compilation errors, 
neither informative about the root of the problem and indicative as to 
how the parameter solves it.

There are two issues here:

1. Once a problem/solution pair of this degree of subtlety crops up, we 
need to convince ourselves that that's sensible. If we deem it not so, 
we look into improving the language to make the problem disappear.

2. There needs to be documentation for people working on the standard 
library so they don't need to waste time on their own discovery process.

We want Phobos to be beautiful, a prime example of good D code. 
Admittedly, it also needs to be very general and efficient, which 
sometimes gets in the way. But we cannot afford an accumulation of mad 
tricks to obscure the large design.


Andrei


More information about the Digitalmars-d mailing list