@Lando here an example for dynamic dispatch on value types.
type
A = object of RootObj
a: string
B = object of RootObj
a:int
method foo(arg: RootObj): void =
discard
method foo(arg: A): void =
echo "A ", arg.a
method foo(arg: B): void =
echo "B ", arg.a
var a = A(a: "abc")
var b = B(a: 12345)
var pointers : array[2, ptr RootObj] = [a.addr, b.addr]
for p in pointers:
p[].foo
var references : array[2, ref RootObj]= [new(A), new(B)]
for p in references:
p[].foo
- ref object or object with ref field mratsim
- Re: ref object or object with ref field Krux02
- Re: ref object or object with ref field Varriount
- Re: ref object or object with ref field Krux02
- Re: ref object or object with ref field Lando
- Re: ref object or object with ref field Krux02
- Re: ref object or object with ref fiel... mratsim
- Re: ref object or object with ref ... Krux02
- Re: ref object or object with ref ... dom96
- Re: ref object or object with ref ... Krux02
- Re: ref object or object with ref ... mratsim
- Re: ref object or object with ref ... Lando
- Re: ref object or object with ref ... LeuGim
- Re: ref object or object with ref ... Lando
- Re: ref object or object with ref ... Krux02
