On Thursday, 31 October 2013 at 18:51:46 UTC, bearophile wrote:
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.


You are expert in making enhacement request :)

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

But I don't believe that D being system laguage will diverge from traidtional C/C++ pointer model. Right, in runtime smart pointers can probably do some job by guessing allocation kind looking at pointer.

Reply via email to