These are good points, Marc. I see your concern. A couple of thoughts.
(3) [...] Chez has `case-lambda' for
optional argument dispatch, but this can be made fast because by
giving not well-known procedures several entry points (one for zero,
one for one, one for two, etc. arguments) so that there is *no*
dispatch argument. I fail to see how this can work with arbitrary
It can stil be fast when
- The callee is known at the compile time and keyword arguments are explicitly provided, or
- The caller doesn't provide keyword arguments at all.
If the callee can't be known at the compile time, the compiler has to fall back
to the generic calling sequence that lets the callee to parse keyword-value list at runtime.
But using macros (in place of keywod-accepting procedures, as suggested in earlier discussion) would
lose the ability to parameterize the procedure anyway.
The compiler can neither optimize when caller provide variables to be evaluated to
keywords in the keyword positions, but I don't recall I ever see such usage, both in
Scheme and Common Lisp.
(4) Keyword arguments as implemented by SRFI 177 are symbolic (as
opposed to hygienic (renamable) identifiers). This feels a bit
un-schemy and not in the trandition to where Scheme has gone since the
R6RS/R7RS. We have already had long discussions on the identifier
status of record field names and SRFI 159 has been revised into SRFI
166 because the state variables were (erroneously) symbolic.
Imho, it should be either symbolic (e.g. always quoted), or all keywords should be imported
from a common namespace. Suppose one library provide a procedure with keyword argument :test
to optionally specify a test pedicate. Another library may also provides a procedure with :test
keyword argument. If they are different identifiers and you want to import from both
modules, you have to rename either one of :test. The combinations can quickly explode.
In other words - locations of posittional parameters aren't subject of hyegene; we don't
import a procedure with its argument swapped, for example. Keyword arguments are just
another way of specifying parameters, it's less about names.
(I do see an argument that it's effectively introducing a special namespace for keyword arguments
and that's ugly. But using hygienic identifiers in keyword naming seems solving a wrong problem, I feel.)