Racket and many other languages have the concept of optional arguments at the receiver side:
Here, the procedure is offering its caller the option of supplying a
foo, and if the caller does not do so, uses
123 as the
value for foo. The caller is permitted not to care (or even to
know!) about the
Almost no language that I know of has the symmetric case: an optional argument at the caller side (and because the feature doesn’t exist, I’m having to invent syntax to show what I mean):
The intent here is that the procedure is permitted not to care (or even to know) about the additional value its caller supplies.
This would be useful for callbacks and other situations where the code invoking a procedure has potentially-useful information that the specific (and statically-unknown) procedure being called may or may not care about.
I said above that almost no languages have this feature: it turns
out that Squeak and
Pharo have something similar in their
BlockClosure>>#cull: methods. The following code works when given a
closure accepting zero, one or two arguments: