UDA and trait for non-GC managed pointers

2016-10-16 Thread Nordlöw via Digitalmars-d
Is there a way to check if a pointer is supposed to point to non-GC allocated memory? I presume not. This is needed to prevent unnecessary calls to `GC.addRange` in containers with elements of a type that in turn is a container-like struct with non-GC allocated memory. If not, maybe we could

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Andrei Alexandrescu via Digitalmars-d
On 10/15/2016 12:22 PM, Nordlöw wrote: Is there a way to check if a pointer is supposed to point to non-GC allocated memory? I presume not. This is needed to prevent unnecessary calls to `GC.addRange` in containers with elements of a type that in turn is a container-like struct with non-GC alloca

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Nordlöw via Digitalmars-d
On Saturday, 15 October 2016 at 17:11:28 UTC, Andrei Alexandrescu wrote: Seems there'd be quite some annotational overhead. In the case of a C++-style vector it's just a matter of changing E* _ptr;// non-GC-allocated store pointer to @nogc E* _ptr; // GC-allo

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Nordlöw via Digitalmars-d
On Saturday, 15 October 2016 at 17:19:53 UTC, Nordlöw wrote: E* _ptr;// non-GC-allocated store pointer to @nogc E* _ptr; // GC-allocated store pointer should, of course, be E* _ptr;// GC-allocated store pointer to @nogc E* _ptr;

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread ag0aep6g via Digitalmars-d
On 10/15/2016 07:19 PM, Nordlöw wrote: and then updating the relevant trait, such as `hasIndirections` or/and `hasAliasing`, to respect this attribute. How would those traits have to updated? An indirection is an indirection no matter if it points to GC memory or not. Maybe we'd need a new tra

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Basile B. via Digitalmars-d
On Saturday, 15 October 2016 at 16:22:35 UTC, Nordlöw wrote: Is there a way to check if a pointer is supposed to point to non-GC allocated memory? I presume not. This is needed to prevent unnecessary calls to `GC.addRange` in containers with elements of a type that in turn is a container-like s

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Nordlöw via Digitalmars-d
On Saturday, 15 October 2016 at 17:48:13 UTC, Basile B. wrote: To be honest I find this system way more useful that the function attribute @nogc. My trait is here (https://github.com/BBasile/iz/blob/master/import/iz/memory.d#L145) but it's quite similar to the one used in EMSI containers (with d

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Nordlöw via Digitalmars-d
On Saturday, 15 October 2016 at 17:48:13 UTC, Basile B. wrote: I agree. We are several people to do it already. I've started to during last spring (see https://forum.dlang.org/post/ficbsdfokvbvslatm...@forum.dlang.org). So far I use "@NoGc" and "@TellGcRange" added. Why does the template argu

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Basile B. via Digitalmars-d
On Saturday, 15 October 2016 at 19:36:19 UTC, Nordlöw wrote: On Saturday, 15 October 2016 at 17:48:13 UTC, Basile B. wrote: I agree. We are several people to do it already. I've started to during last spring (see https://forum.dlang.org/post/ficbsdfokvbvslatm...@forum.dlang.org). So far I use

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Chris Wright via Digitalmars-d
On Sat, 15 Oct 2016 16:22:35 +, Nordlöw wrote: > Is there a way to check if a pointer is supposed to point to non-GC > allocated memory? You can check if it *does* point to GC-allocated memory if you use GC internals -- the Pool struct is what you want to look at, and the lookup methods ass

Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Nordlöw via Digitalmars-d
On Sunday, 16 October 2016 at 04:14:42 UTC, Chris Wright wrote: On Sat, 15 Oct 2016 16:22:35 +, Nordlöw wrote: Is there a way to check if a pointer is supposed to point to non-GC allocated memory? You can check if it *does* point to GC-allocated memory if you use GC internals -- the Pool

[OT] Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Basile B. via Digitalmars-d
On Saturday, 15 October 2016 at 18:03:54 UTC, Nordlöw wrote: On Saturday, 15 October 2016 at 17:48:13 UTC, Basile B. wrote: To be honest I find this system way more useful that the function attribute @nogc. My trait is here (https://github.com/BBasile/iz/blob/master/import/iz/memory.d#L145) but

Re: [OT] Re: UDA and trait for non-GC managed pointers

2016-10-16 Thread Nick Sabalausky via Digitalmars-d
On 10/15/2016 02:50 PM, Basile B. wrote: I've given up with the idea of proposing my stuff in phobos. About memory there would also have be: - allocators-based factory (https://github.com/dlang/phobos/pull/4062) - @nogc dispose (https://github.com/dlang/phobos/pull/4351) But each time the PR wa