Email list hosting service & mailing list manager

Getting rid of the ugly call/kw Marc Nieper-Wißkirchen (02 May 2020 21:54 UTC)
Re: Getting rid of the ugly call/kw Lassi Kortela (03 May 2020 12:10 UTC)
Re: Getting rid of the ugly call/kw Marc Nieper-Wißkirchen (03 May 2020 12:28 UTC)

Re: Getting rid of the ugly call/kw Marc Nieper-Wißkirchen 03 May 2020 12:28 UTC

Am So., 3. Mai 2020 um 14:10 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:

> SRFI 177 is getting quite late and there is no obvious

That's not a bad thing per se; it just shows that there is still some
work to be done. It is one of the SRFIs, which not only cover a niche
(like one of the many SRFIs describing data structures), but would
pervade larger parts of the language and the libraries.

> 1) Leave lambda/kw out of 177 altogether. The SRFI would be left with
> only define/kw and call/kw. We can always write an update SRFI to add
> lambda/kw if it proves universally useful.

Adding LAMBDA/KW once DEFINE/KW is fixed, is always possible (unless
"procedures" taking keyword arguments are macros) so we don't have to
worry about that.

> Though identifier syntax might be a good way to implement keyword
> lambdas in general, it's not currently widely portable so it's not a
> good fit for 177. A keyword procedure needs to be either an ordinary
> lambda or an ordinary macro.

This would be an incentive to add identifier macros to the various
Schemes, which should be an easy task because it doesn't interfere
much with the expander. But see below!

> 2) Make define/kw create macros instead of procedures so that call/kw is
> not needed at the call site. I haven't thought about the implementation
> at all, but might this work portably even with syntax-rules and
> define-macro?

Depending on the exact syntax, this is possible with SYNTAX-RULES.
Moreover, this is transparent to whether the macro created by
DEFINE/KW is also an identifier macro or not. (Thus your sentence "a
keyword procedure needs to either an ordinary lambda or an ordinary
macro" is not questionable.)

This would lead to the following not so unpleasant situation:

SRFI 177's DEFINE/KW defines macros that work on all platforms without
crutches like CALL/KW. On those platforms that have identifier macros
or other tools to implement this, these macros can also be used in
place of variable references where a procedure taking keyword
arguments is returned (and for which CALL/KW and APPLY/KW will be
needed).