Am Mi., 9. Juni 2021 um 19:23 Uhr schrieb John Cowan <xxxxxx@ccil.org>:

On Wed, Jun 9, 2021 at 5:42 AM Daphne Preston-Kendal <xxxxxx@nonceword.org> wrote:

I considered the possibility of making everything a macro, but I decided losing first-class status of procedures was too high a price to pay, on principle if nothing else. True, it's unlikely (though not impossible) that an arbitrary higher-order procedure (as in map, fold and their respective first arguments) will use keyword arguments, but I can imagine not-so-contrived situations where it would still be useful to pass them around.

But perhaps it would be acceptable to have something where you'd define a version of a procedure with positional arguments which is first-class, then a meta-macro to get a keyword version of it? Hmm.

I'm thinking of a variant of this: the keyword-accepting procedure is really a macro that sorts the keyword arguments and passes their values as positional arguments to an internal procedure.  Thus (foo a b c :y y :x x) applies the internal procedure to (foo a b c x y).  This would not apply to systems with native keywords: the macro would just map the standard convention for keywords to the native one.  So we get a bridged implementation.

Now if the macro is syntax-case, (map foo ...) will be recognized as a macro call.  But if it is ER, we need a mechanism for referring to the external procedure directly.

Could you elaborate on this? Unless "map" is a macro, "foo" will resolve to some runtime value. Maybe I am missing the point here. (Additionally: In what sense does the distinction between syntax-case and ER macros play a role here? It seems only relevant insofar as syntax-case implementations usually support identifier syntax, but ER could as well.)
There are two ways to access the internal procedure: give it a magic name (e.g. for the keyword procedure foo the internal procedure is foo%) or have a universal magic token, such that when the macro is called with this token as its only argument, it does not call the internal procedure but instead returns it.  So to apply you use not (map foo ...) but (map (foo %magic-token) ...).

A clean way would be SRFI 213, which I would like to advocate for inclusion into R7RS-large, by the way.