Re: Keyword arguments in procedures specified in SRFIs Lassi Kortela 22 Jul 2019 19:32 UTC

Thanks for joining in Peter!

>> As a data type, are keywords a subtype of symbols or disjoint from them?  I
>> think they are generally a subtype, but they are disjoint in Chicken.
>
> They were a subtype, but that caused all sorts of confusion.

Good points.

Common Lisp sidesteps the problem because every CL symbol has both a
symbol name (as in Scheme) and info about which package (i.e. namespace)
it belongs to. So keywords are just symbols in the special KEYWORD
package. Since they are in a separate package:

* It's easy to for `let`, etc. to forbid binding them.

* They can have the same names as other symbols without problems. E.g.
(symbol-name :foo) and (symbol-name 'foo) both return "FOO". In Scheme,
if keywords were a subtype of symbols, we'd have to think carefully
about what (symbol->string) returns for keywords.

* They do not compare equal to other symbols with the same name.

Since symbols aren't divided into packages in Scheme, it does indeed
seem difficult to think of a problem-free way to make keywords a subtype
of symbols.