For example, suppose that
foo is defined like this.
foo[x_Integer, y_Integer] := x + y;
Then, any expression with head
foo that does not match the pattern given above will remain "unevaluated". E.g.,
foo "evaluates" to
Although I recognize that there are situations where one may want precisely this behavior, in most of my programming I don't. Quite the contrary: I want expressions like
foo to be treated as malformed, IOW, as errors, and therefore to result in a loud, unequivocal failure whenever they are evaluated.
Hence, I find myself writing a lot of code of the form
foo[x_Integer, y_Integer] := x + y; foo[___] := Abort;
(Actually, I use a slightly embellished version of
But including a line like
foo[___] := Abort;
for every function one defines adds up to a lot of hard-to-maintain clutter-code.
Does Mathematica have some other way to achieve the same thing with less clutter?