Re: Keywords reduced Marc Nieper-Wißkirchen 21 Oct 2019 07:01 UTC

Am Mo., 21. Okt. 2019 um 00:05 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> On Sun, Oct 20, 2019 at 11:33 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
>>
>> Am So., 20. Okt. 2019 um 23:19 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>>
>> (Thinking of parameter objects... what can keyword arguments do what
>> parameter objects and parameterize cannot already do?)
>
>
> You can emulate keyword arguments with parameterize but it'll be super awkward.
>
> Suppose f and h takes both test: argument, with the same meaning.
>
> f also takes a procedure and call it without arguments.
>
> If we say (f h test: equal?), we know f is called with test: eqv?, and h is called without arguments so
> it uses whatever the default value of test: argument.
>
> Using parameterize, we need to do
>
>    (parameterize ((test equal?))
>        (f (lambda () (parameterize ((test <the default value of test>))
>                                 (h)))))
>
>

I agree that this is (too) awkward. If SRFI 157 is available, one
could use `call-with-immediate-continuation-mark' to set keys only in
the current call. This however, will still not work if `h' is called
from `f' in tail position as it will reuse `f''s continuation frame.

Maybe some syntactic sugar over `parameterize' can help. I have to
think about it.