Re: Keyword arguments in procedures specified in SRFIs Per Bothner 22 Jul 2019 05:44 UTC
On 7/21/19 1:49 PM, John Cowan wrote: > Racket keywords have the form #:foo and are part of the syntax of function calls rather than a self-evaluating literal. In newer versions of Kawa too keywords are syntax rather than self-evaluating literals. You can quote a keyword, but in that case it just evaluates to a Keyword value, bu a Keyword value in a argument list is *not* a keyword parameter. See: https://www.gnu.org/software/kawa/Primitive-expression-syntax.html#Procedure-calls https://www.gnu.org/software/kawa/Application-and-Arguments-Lists.html The Common Lisp keywords-are-self-evaluating model has the advantage of simplicity, but the Kawa/Racket model has some advantages, mtoo, ost importantly static analysis is easier: * When calling a known procedure the compiler can statically determine if a keyword actual argument is valid. (Not yet implemented in Kawa.) * Easier to generate efficient code. The Kawa calling convention involves sorting the keywords at both the caller and callee sites. This can be done at compile-time: For the callee, assuming the callee doesn't allow "other keywords"; for the caller, assuming argument-list objects aren't used. In that case argument matching is very fast, without requiring any form of hash table: A simple linear scan of the caller and callee keyword lists. In addition to being fast, it requires less space than a hash table. -- --Per Bothner xxxxxx@bothner.com http://per.bothner.com/