Commonly used in Scala libraries is the
require method. For good reason, of course, we want our parameters in a specific way. However, this method does incorporate some overhead to the method call. For user input, this is obviously unavoidable, but for other parameters, I don’t see why a compile-time check can’t be added.
I propose a new syntax to parameters on methods (or constructors, etc, etc) that tells the compiler how to prune and validate input to this method. If the value is indeterminate at compile-time, it can be redirected to a
Adversely, I don’t see a way this could be done without generating a duplicate method in the bytecode, one with the
require call and one without.