On Saturday, 13 September 2014 at 19:58:16 UTC, Kagamin wrote:
On Saturday, 13 September 2014 at 18:36:53 UTC, Timon Gehr
wrote:
On 09/13/2014 07:48 PM, Kagamin wrote:
On Saturday, 13 September 2014 at 16:51:09 UTC, Timon Gehr
wrote:
s.bar((int* p){ ++*p; });
Huh? inout is for functions, which don't modify their
arguments.
With Jakob's code working, this would not be warranted.
Huh? See rationale in
https://issues.dlang.org/show_bug.cgi?id=1961
The function doesn't modify `p` - it's modified by a callback
that was accepted because it's known at the call-site that `p` is
modifiable.
This is necessary for `inout` to work with callback functions,
such as with internal iteration (i.e. `opApply`). It can be
worked around exactly the same way you would work around it with
functions that return a value - by duplicating the function. It
is essentially the same problem and thus `inout` could easily be
used to fix it.