> Regarding pointers being the only option for polymorphic returns; I guess 
> this depends on the object layout used? For instance, I assume object variant 
> does not need to be same size but still allows polymorphism in return value, 
> simply by reserving space for the biggest variant in the calling stackfram.

Object variants are not polymorphism (at least not in the computer science 
semantics of the word). But you are right, it works because it reserves the 
size of the largest possible variant. One obvious difference to polymorphism is 
that whoever defines the object type has complete control over any variants. 
With polymorphism, a user of your type can define a new subtype. This is why 
using `if v of SomeType` is bad style – you cannot know all derived types, 
because other code using your code may define new derived types.

Reply via email to