Hello!,
I have been struggling to find a way to copy a field to another one, both chosen at runtime from a "sampler", the details of which are irrelevant, but it returns an int that corresponds to the order in which the fields are encountered. Obviously both need to be of the same type.
So with our destination being 4, type "float" from the object Foo(a: 1, b: 2, c: new(float), d: true) that is actually .c[]. Source is 7 from Foo(a: 3, b: 4, c: nil, d: true, next: Foo(c: new(float))), that is .next.c[].
So far I have actually implemented this with generics and recursion http://ix.io/45Jw However I feel like the solution is frankly very ugly, and could lead to stack overflows. Is there a better way to achieve this?