Re: allow-other-keys Marc Nieper-Wißkirchen 03 Nov 2019 18:47 UTC

Am So., 3. Nov. 2019 um 12:39 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:
>
> >> Do you mean that e.g. `open-output-file` as an identifier would evaluate
> >> to a genuine lambda, whereas `(open-output-file ...)` would be a macro
> >> that expands to the keyword argument checking and finally a fast call to
> >> a lambda?
> >
> > Yes, this is possible and all that would be needed if we do not treat
> > keyword arguments as first class objects (that can be forwarded).
>
> It's worth thinking about this from a reflection standpoint too. Though
> Scheme is designed with a focus on compilation, and reflection doesn't
> need to be standardized in RnRS, is very useful in several implementations.
>
> It should be possible to get the full argument list of a keyword
> procedure if an implementation wants to provide that (for code
> completion, etc.) If the identifier-syntax evaluates to a first-class
> procedure, maybe the procedure object can have some
> implementation-defined metadata tagged onto it. But then you can't call
> that object with the keywords. Well, there could still be a separate
> call-kw-object macro. Here the semantics start to get more complicated
> when we deviate from standard lambdas; that's why my intuition suggested
> staying with them. But all of this is still possible to handle in principle.

Note that an implementation is allowed to implement any procedure as a
combo of a macro and a procedure using the identifier syntax trick. If
I am not mistaken, this is the trick by which Chez Scheme, for
example, makes procedures exported by libraries inlineable.

Thus, whatever reflection works with ordinary Scheme procedures will
also work with procedures taking keyword arguments that are
implemented using a macro/procedure combo.

The nice thing about it would be that we wouldn't need "call/kw" most
of the time.

-- Marc