Re: Remaining keyword problems Lassi Kortela 11 Nov 2019 16:15 UTC

> After having thought about it again, I think there is a way out:
>
> We write keywords in the form "foo" or "foo:" (assuming that the
> latter is the datum representation of a native keyword). The
> implementation of SRFI-177 uses `syntax-rules' to match the keywords,
> that is native keywords like "foo:" are matched with "equal?" and
> identifiers are matched via "free-identifier=?", that is hygienically.
>
> What does it mean from a practical point of view?
>
> If a consumer of SRFI 177 needs hygienic keywords, no problem.
>
> For all others (probably the majority), just use keywords of the form
> "foo:". For Scheme systems supporting SRFI 88, they will be read as
> keywords and just matched via "equal?". For Scheme systems, reading
> things like "foo:" as identifiers, the matching will be through
> "free-identifier=?", which, however, is the same as "equal?" if "foo:"
> is not bound! (Which it usually is.)
>
> I think this situation is perfect in the light of that R7RS-large may
> include native keywords later. Use the syntax "foo:" already now and
> just make a note that identifiers of the form "foo:" mustn't be bound
> (which they cannot in systems supporting SRFI 88 anyway).

This is terrific if it works.

I didn't quite understand the details. Do you mean that in the portable
implementation where keyword arguments are passed as a plist rest
argument, call/kw would simply destructure pairs of the form

(key1 value1 key2 value2)

without caring what types of objects key1 and key2 are. And lambda/kw
would generate code that uses a `case` expressions to destructure the
plist like this:

(case this-keyword
   ((key1) (set! variable1 this-value))
   ((key2) (set! variable2 this-value))
   (else (error ...)))

And since both lambda/kw and call/kw are defined using syntax-rules, the
key1 and key2 would be hygienic automatically if they are not keyword
objects?