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

Am Mo., 21. Okt. 2019 um 00:18 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:
>>
>> I definitely don't want to bring the identifier into the run-time, but
>> I don't think that it is needed. Whenever a hygienic keyword is
>> created (that is where `test:' is bound), an internal counter value
>> could be recorded with the binding.
>>
>> (test: eqv?)
>>
>> would then become something like `(12345678 #<procedure eqv?>)' where
>> `12345678' is a unique number or unique location in the store (think
>> of the generative records of R7RS). Keyword argument lists could then
>> also be modeled through hash tables instead of alists.
>
>
> That seems workable.
>
> Actually, in Gauche, a keyword (noted like ':foo') is just a symbol.  However, it is automatically bound
> to itself in a library (gauche keyword), so if you import that library, you can say (f :foo x) which is effectively
> the same as (f ':foo x).
>
> But you can also make a library that exports :foo to a unique value in the library.   Hygiene applies to
> resolve bindings so you can use both :foo without conflict:
>
>    (import (rename (gauche keyword) (:foo g:foo))
>                (my library that exports :foo))
>
>    (f :foo x g:foo y)
>
> Note that we still deal with runtime value to match keyword arguments; so your performance concern
> is still there, but is'nt hygiene concern addressed with this?

With respect to hygiene this looks good!

But doesn't it preclude most optimizations with respect to keyword
arguments? Assume that `f' is well-known at the call site. How can
Gauche optimize the example

(f :foo x g:foo y)

into a call that does not need any run-time comparison because
everything is known at compile-time, in principle.

Marc