On Thursday, 13 May 2021 at 13:45:50 UTC, Adam D. Ruppe wrote:
On Thursday, 13 May 2021 at 13:30:29 UTC, Alain De Vos wrote:
Or have I a wrong understanding of pure or the compiler.
pure means it doesn't depend on any mutable info outside its
arguments.
You are only working on the arguments there so it is ok.
Then D's pure does not match up with WP's definition [1] of pure,
at least not
2. The function application has no side effects (no mutation
of local
static variables, non-local variables, mutable reference
arguments
or input/output streams).
WP quotes Bartosz Milewski:
2. A function has no side effects. Calling a function once is
the same as
calling it twice and discarding the result of the first call.
[1] https://en.wikipedia.org/wiki/Pure_function