Nested Structs (Solution)
js.mdnq
js_adddot+mdng at gmail.com
Sun Dec 16 00:09:39 PST 2012
On Sunday, 16 December 2012 at 01:04:44 UTC, Rob T wrote:
> There's an interesting discussion going on that may be related
> to this subject.
>
> http://forum.dlang.org/thread/mailman.2705.1355596709.5162.digitalmars-d@puremagic.com
>
> Note the definition with the "hidden reference frame" baggage,
> and to get rid of the extra baggage use "static struct".
>
> The reference frame mentioned however is not for a parent class
> or struct, but maybe its similar enough that nested structs
> could possibly be extended with a hidden reference to the
> parent class or struct.
>
> It all seems debatable though with various levels of
> complications associated with implementing a nest struct.
>
> --rt
I was just looking at that and thought it was pretty interesting
and that maybe the technique I used might apply. But after second
thought I don't think it will work because copies of the struct
are passed around instead. Which, if you recall, is still
somewhat of an issue with the nested struct model I'm using. Of
course, with overrides of opAssign, this, and opCast one could
possibly avoid this issue too.
It seems to me that the stack frame has taken place of the class
object. When the voldemort struct is returned from the function,
the outer values come from the stack frame(rather than the class
object). When you return the voldemort struct, it also orphans it
in a similar way it does for the class object. That is, unless
the stack frame is always correct, which I haven't convinced
myself of yet.
Although I have a solution using the nested struct idea
directly(simply use a functor), I think will work... I'll post
it on the other thread. (this might imply that the voldemort
construct is pretty solid, or can be made to be so)
More information about the Digitalmars-d
mailing list