Yes, but variant objects are special beasts as it is indeed forbidden to change 
individually the value of the discriminator, except by globally assigning the 
object.

This was not always the case. I remember some versions of Nim which allowed to 
change the discriminator value. I don’t know what Nim used to do in this case 
to invalidate the memory area which became invalid. In languages which doesn’t 
forbid the change, some code has to be generated to reset the memory area. In 
Pascal, nothing was done at all, at least, by the compilers I used.

Nim has now this limitation which makes the construction syntax unavoidable. 
This is not a bad thing, but in some cases I suppose it may cause some more 
memory copies.

Reply via email to