Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 08, 2014 std.variant, elaborate copying and GC | ||||
---|---|---|---|---|
| ||||
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. |
April 08, 2014 Re: std.variant, elaborate copying and GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuriy | Sorry for all the typos. It's been a long day =). |
April 08, 2014 Re: std.variant, elaborate copying and GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuriy | 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.
|
April 08, 2014 Re: std.variant, elaborate copying and GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rene Zwanenburg | 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? |
Copyright © 1999-2021 by the D Language Foundation