DIP25 draft available for destruction
kenji hara
k.hara.pg at gmail.com
Wed Feb 6 00:22:08 PST 2013
2013/2/6 Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>
> 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- at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130206/c619d886/attachment.html>
More information about the Digitalmars-d
mailing list