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)

Getting rid of the ugly call/kw Marc Nieper-Wißkirchen 02 May 2020 21:54 UTC

One of the main arguments (no pun intended) against the current
proposal of how to do keyword arguments is the need to call a
procedure through the CALL/KW macro when one wants to deliver optional
keyword arguments to the procedure.

Changing the name to something shorter does not really solve the
principal issue.

If, on the other hand, the procedures that can receive keyword
arguments are defined as syntax, no CALL/KW prefix is required at all,
and optimizing calls with optional keyword arguments comes for free.

While this alternative approach will be most adequate in 95% of the
use cases, it won't work when we want to pass around the "procedure"
as a value because it is actually a syntactic keyword.

So the "procedure" has not only to be defined as a syntactic keyword
in the sense of R7RS-small, but the keyword has also to function as an
identifier macro so that a first-class value can be passed around.
This first-class value is an ordinary procedure.

In order to call this procedure with keyword arguments, one finally
needs CALL/KW or a more general APPLY/KW, but this is probably fine
because this will only be needed in 2% of the cases.

In some sense, this breathes a bit of a Lisp-2 (although in another
sense) into Scheme, but it is the best we can do without a general
macro like Racket's #%app.

What do you think? I think I can provide an implementation. (This
implementation will need identifier macro support from the Scheme
system to make the "procedures" taking keyword arguments truly
first-class citizens but incorporating identifier macros in any Scheme
expander seems like a simple task independent of the underlying
low-level macro system and we may see them standardized in R7RS-large