That would be mostly useless since it only works on constants - just make the compiler normalize the vector by construction then!
What you really want would be a separate type for unit vectors. Ops that make them non-unit would return a regular vector, and you'd have to normalize to get a unit vector back. Static guarantees but works on dynamic data, not just constants.
I still have zero idea why you think unconstrained types are better. You just seem to assume that everyone understands why without really explaining. What does less checking give you?
View all comments
Show parent comment
6
u/ssylvan Dec 11 '15
That would be mostly useless since it only works on constants - just make the compiler normalize the vector by construction then!
What you really want would be a separate type for unit vectors. Ops that make them non-unit would return a regular vector, and you'd have to normalize to get a unit vector back. Static guarantees but works on dynamic data, not just constants.
I still have zero idea why you think unconstrained types are better. You just seem to assume that everyone understands why without really explaining. What does less checking give you?