Okay, now suppose I write a second function - let's call it tolower(), which lowercases a string, again represented as one of the UTFs. Again, I guess I'm supposed to validate the input. yes?
And yet, in an expression such as tolower(trim(s)), the second validation is unnecessary. The input to tolower() /must/ be valid, because it is the output of trim(). But on the other hand, tolower() could be called with arbitrary input, so I can't skip the validation.
For efficiency, I /could/ assume that all input was already valid - but then, what if it isn't? Or I could validate all input - but that's inefficient. Or I could write two versions of each function, one validating, the other not, but that adds too much complexity. It seems to me that not validating input to such functions would give you the best performance, but then in order to remain compliant you'd have to do the validation somewhere else - for example something like
t = tolower(trim(validate(s))).
where validate(s) does nothing but throw an exception if s is invalid.
Other people must have had to make decisions like this. What's the preferred strategy?
Arcane Jill

