Why are you using ptrs instead of refs?

You could do "type person = object[id:int;name:string]; type male=distinct ref 
object of person; type female=distinct ref object of person;" to get an 
equivalent effect (while dropping ptrs for refs).

However, I highly recommend instead having a "type person = 
tuple[id:int;name:string;isMale:bool]" which would take a tiny bit more space 
but would make your code considerably simpler.

The argument against my proposal would be: If you encode the constraints into 
the type system, the compiler can validate a lot of things for you -- which is 
correct, and which I support when it does not result in code duplication; 
However the issue is that in this case it results in a lot of duplication (some 
of which can be reduced, but not all).

Reply via email to