I have this object hierarchy with some fields :
TMedia* = ref object of RootRef
TVideo* = ref object of TMedia
TImage* = ref object of TMedia
TWebPage* = ref object of TMedia
proc setNewDims(arr:seq[TMedia])=
discard
Run
if i pass a seq[TVideo] to setNewDims, the compiler complains that it must be a
seq[TMedia]. But since TVideo is also a TMedia isn't seq[TVideo] also a
seq[TMedia]? Then why it doesn't work? Is it because under the hood seq are
pointers and to go from one TMedia obj to the next the compiler must know the
size of the object? So at runtime, if i pass a seq[TVideo] the compiler,
thinking it's a TMedia, would add the size of a TMedia to go to the next item
and doing so would screw things up. Right? Is there a way to solve this
problem? Sometimes you need to have as argument to a proc a seq of the base
type and not just an object of that type