Re: Keywords reduced Lassi Kortela 22 Oct 2019 10:56 UTC

> Lassi mentioned somewhere that the shape of the high-level interface
> of this SRFI 177 was partly dictated by the limitations of
> `syntax-rules'.

It's the (a b c (k1 k2 k3)) format.

Using define-macro (or perhaps syntax-case), since the macro can inspect
`a`, `b`, `c`, `k1`, `k2`, and `k3`, it could look for the first keyword
object (or in Schemes that don't have keyword objects, some kind of
stand-in such as a quoted symbol).

Since a syntax-rules macro has to treat those as opaque identifiers, we
need to rely on the list structure (outer-list ... (inner-list ...)) to
split keywords from positional arguments. Even that relies on a
syntax-rules extension, tail patterns. We could put the keywords at the
start like ((keywords ...) positionals ...) but that doesn't read
naturally; keyword arguments are written at the end of the call in all
languages that have them, including Schemes and other Lisps.

It might be possible to use a symbol as a magic marker:

(keyword-call a b c magic-here k1 val1 k2 val2 k3 val3)

IMHO that would be a worse alternative than (a b c (k1 val1 k2 val2 k3
val3)).