digitalmars.D.learn - std.variant, elaborate copying and GC
- Yuriy (11/11) Apr 08 2014 Hello, i've been playing around with std.variant and noticed,
- Yuriy (1/1) Apr 08 2014 Sorry for all the typos. It's been a long day =).
- Rene Zwanenburg (5/9) Apr 08 2014 It won't. There has been some work on a precise GC but I don't
- Yuriy (5/5) Apr 08 2014 Ah, now that's clear. Ok, what about the other question? E.g. I'm
Hello, i've been playing around with std.variant and noticed, that it does not support elaborate copying, when a struct uses one. So the question is whether it is intended or not. If yes, std.variant should probably prohibit usage of such structs. If no, then it we will need to add a destructor and, and handle destruction in std.Variant.handler, which will introduce some performance drop. Also, i can't completely understand how garbage collection works. E.g. setting an instance of a class to std.variant will copy its reference to variant's internal storage, which is void[]. Will GC loose track of such reference? Thanx.
Apr 08 2014
Sorry for all the typos. It's been a long day =).
Apr 08 2014
On Tuesday, 8 April 2014 at 16:03:01 UTC, Yuriy wrote:Also, i can't completely understand how garbage collection works. E.g. setting an instance of a class to std.variant will copy its reference to variant's internal storage, which is void[]. Will GC loose track of such reference? Thanx.It won't. There has been some work on a precise GC but I don't know how much is being used at the moment. In any case, for untyped memory the GC will assume the worst and treat every word as a potential pointer.
Apr 08 2014
Ah, now that's clear. Ok, what about the other question? E.g. I'm trying to implement a bridge to C lib with reference counting. My "references" are structs. Ctor retains, dtor releases, assign does both. Looks like my struct can not be used with variants. Should i submit a pull to fix that?
Apr 08 2014