On Thursday, 24 January 2019 at 23:18:11 UTC, kinke wrote:
Proposed `out` semantics:
---
void increment(out long value) { ++value; }
increment(out value);
---
vs. pointer version with current `out` semantics:
---
void increment(long* pValue) { ++(*pValue); }
increment(&value);
---
The pointer workaround is both ugly (C) and unsafe (you can
pass null).
@safe void safestFunction() {
int* ptr;
increment(out *ptr); // can also pass null to ref/out even in
@safe
}
It's probably going to be a hard sell to change the behavior of
out now as well. It'd break quite a bit of code I think, did a
search through druntime and phobos and quite a few functions use
it. Maybe user code uses it less, I know I never use it.