
Edward Diener wrote:
Suppose the value is provided by the end user of the program.
Then the programmer should check its value before assigning it into the constrained type, like I just said. A constrained type is just a type that must maintain an invariant, and it should be up to the programmer to ensure that the necessary preconditions for the invariant are always met, and assertions are here to help him do just that.
A large part of the constrained value concept is that the constraint provides the necessary checking, in the form of a policy, which alleviates specific pre-checking by the programmer. I like that, else the constraint library serves less purpose than it could.
To me, that makes it useless, because that's adding runtime checks where it is not always needed, potentially adding quite some overhead. At least it's configurable, but the default behaviour isn't the right one IMO.