Re: allow-other-keys Lassi Kortela 29 Oct 2019 23:04 UTC

> I wonder if such "wrapper" procedure can be written portably in srfi-177.
> Say, we have 'inner' which takes
> two required arguments and some keyword arguments, and we want to wrap it
> with 'outer' which recognizes
> additional 'x' and 'y' keyword arguments.  What I can think of is something
> like this:
>
> (define (outer a b . rest)
>     (define outer-adapter (keyword-lambda ((x y))
>          (let ((inner-kv-args (delete-keywords '(:x :y) rest)))
>             (apply inner a b inner-kv-args)))
>     (apply outer-adapter rest))
>
> 'delete-keywords' is Gauche-specific and need to be replaced with the
> portable one, but having wide variety
> of what keyword is, it may be difficult.
>
> By the way, can we 'apply'  keyword-taking procedure to the keyword-value
> list?   Is it that some implementation
> doesn't even allow it?

Since the current simple semantics of 177 have stood up to a lot of
scrutiny so far, I would vote to keep them. (We can still fine-tune the
syntax.)

It would be quite easy to have another SRFI that provides an
`extended-keyword-lambda` with allow-other-keys handling. Can SRFI 89
already do everything needed?

Since allow-other-keys only concerns `keyword-lambda`, and
`keyword-call` doesn't need to care about it, SRFI 177 `keyword-call`
(as well as implementation-native syntax) could be used to call
procedures defined with `extended-keyword-lambda`.

Obviously `extended-keyword-lambda` should have some better name :) SRFI
89 has `lambda*` and a few Schemes have that. I would prefer 177 not to
define `lambda*` since it's not easy to make one with SRFI 177 semantics
using a subset of SRFI 89 syntax (89 relies on keyword objects which 177
cannot rely on).