It turns out it's quite hard to have @safe pure nothrow functions. Oh, and const.
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 13 11:36:51 PDT 2014
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. (But the
situation needs to change in any case. The inout delegate semantics DMD
2.066.0 implements cause type unsoundness as explained here:
https://issues.dlang.org/show_bug.cgi?id=10850 .)
If inout should still guarantee non-modification in the future, then
nested inout functions will need to introduce their own inout context
(i.e. the inout qualifier of the nested function should be incompatible
with the inout qualifier of the enclosing function.) I assume this is a
major PITA to implement in DMD, and it also leads to growing pains that
are hard to counter without enhancing the syntax, hence the current
semantics.
In any case, why is it important that inout functions are guaranteed not
to change their arguments, even if they are mutable and the mutation is
from within a delegate that was passed to such functions for this purpose?
More information about the Digitalmars-d
mailing list