2013/2/6 Andrei Alexandrescu <[email protected]> > Probably it'll need a fair amount of tweaking. Anyhow it's in destroyable > form. > > http://wiki.dlang.org/DIP25
Hmm, this is much reasonable. In recent, I had wrote and post a compiler extension to reinforce a kind of trait which related to pure function. I call the trait "isolated", and that means "Whether any reachable indirections from parameters does not appear in the returned value". https://github.com/D-Programming-Language/dmd/pull/1519 With my patch, such as following cases can be detected. struct S { int* ptr; } S foo(int* ptr) pure; S bar(const int* ptr) pure; void main() { int n; immutable S s = foo(&n); // implicit conversion from S to immutable S is _diallowed_. // Because &n may appear in foo's returned value. immutable S s = bar(&n); // implicit conversion from S to immutable S is _allowed_. // Because &n never appear in bar's returned value. // (compiler assumes that bar doesn't do any un-@safe operations, e.g. cast(int*)ptr) } As far as I see, the contained essence in the DIP is much similar to the "isolated" traits. So I can say that it is *implementable*. Kenji Hara
