It would be nice to have a destructor for each concrete instantiation of struct, in order to then detect if any type in the current struct is another struct. This would also remove the need of struct generics to only be SomeNumber.
The new destructor would be triggered in the init function, which would add type information to a compile time table[string, NimNode] that will contain then all the information to build all the needed destructors.
Refer to newDestructors.nim and to this:
{.push experimental: "codeReordering".}
type
Obj[T] = object
val : T
let one = Obj[string](val : "hi")
let two = Obj[float](val : 0.5)
let three = Obj[int](val : 1)
fun(one)
fun(two)
fun(three)
proc fun(a : Obj[string]) : void =
echo "stringy string"
proc fun(a : Obj[float]) : void =
echo "floaty float"
proc fun(a : Obj[int]) : void =
echo "inty int"
{.pop.}
It would be nice to have a
destructor
for each concrete instantiation ofstruct
, in order to then detect if any type in the currentstruct
is anotherstruct
. This would also remove the need ofstruct
generics to only beSomeNumber
.The new
destructor
would be triggered in theinit
function, which would add type information to a compile timetable[string, NimNode]
that will contain then all the information to build all the needed destructors.Refer to
newDestructors.nim
and to this: