structs holding on to reference data by pointer
bearophile
bearophileHUGS at lycos.com
Thu Oct 31 11:51:45 PDT 2013
Maxim Fomin:
> You can check whether data is on heap, stack, tls, or just
> global object by inspecting pointer at runtime. Ideally there
> would be such function in druntime.
This seems like a nice enhancement request for Bugzilla :-) Are
you going to open it? It seems useful for me too.
> It is impossible to do this in CT (except if comiler support
> flow analysis and can prove in some scenarious that data is on
> stack or not, but due to separate compilation it is impossible
> to do in general case) (and probably shouldn't).
You can do it even with separate compilation (at compile time) if
your language has different kinds of pointers as Rust. Perhaps in
D this can be done using Phobos-defined smart pointers.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list