On Sun, Jul 21, 2019 at 3:42 PM Lassi Kortela <xxxxxx@lassi.io> wrote:

Is there a convention for what SRFI authors should do when the situation
calls for a procedure with keyword arguments? 

I personally prefer using a p-list argument, which can be generated with quasiquotation.  An alternative is to use variadic arguments in the form of a p-list.   But that's just me.

Another option is to pass in a struct or an opaque object. This is a
better option for many of the situations best addressed by keywords, but
the problem then is that the SRFI has to specify more definitions so
users can create and access/mutate the opaque objects.

Plus the usual problems with cross-SRFI record types.
BTW, is there a dependency graph somewhere about which SRFIs depend on
which other SRFIs?

Not at present.  There are several SRFIs now which depend on comparators, but in general I at least try to avoid cross-SRFI dependencies in SRFI specs (implementations are another matter).  SRFI 89 depends on 88.
The only keyword SRFI seems to be Marc's SRFI 88:
Keyword objects which specifies foo:. Are :foo and #:foo standardized

foo: is standardized in DSSSL (ISO/IEC 10179:1996), which is a mutation-free variant of R4RS used as an SGML style language analogous to XSLT.  :foo is Common Lisp.  <https://bitbucket.org/cowan/r7rs-wg1-infra/src/default/KeywordSyntax.md> shows what different implementations accept.

Racket keywords have the form #:foo and are part of the syntax of function calls rather than a self-evaluating literal.  This requires a special procedure keyword-apply to invoke procedures that accept keyword arguments.  It takes a list of quoted keywords, a list of their respective values, and a list of ordinary non-keyword arguments.  Ordinary apply can be used too, but then none of the keyword arguments will have values.

The portable Chibi library (chibi optional) is packaged but not documented on line: it supports the following:

(keyword-ref plist key [default]) 

Search plist for key, returning its value, or default if not found (the default default is #f).

(keyword-ref* plist key default)  [syntax]

The same, but does not evaluate 'default' unless the search fails.  [IMO it would be better to allow keyword-ref to take optional failure and success thunks.]

(let-keywords plist ((var [keyword] default) ... [rest]) body ...)  [syntax]

Binds vars to corresponding keyword values for the scope of body.  If the keyword is not specified, it defaults to the name of the var with a colon appended.  Rest is bound to any non-keyword arguments.  

(let-keywords* plist ((var [keyword] default) ... [rest]) body ...)  [syntax]

The let* version of let-keywords.

The library also supports let-optional, let-optionals*, and opt-lambda macros for handling optional arguments.  The two groups of macros don't interoperate well, but IMO procedures should not have both optional and keyword parameters anyhow.

John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
That you can cover for the plentiful and often gaping errors, misconstruals
and disinformation in your posts through sheer volume -- that is another
misconception.  --Mike to Peter