Re: Keywords reduced Marc Nieper-Wißkirchen 20 Oct 2019 08:39 UTC

Am Sa., 19. Okt. 2019 um 20:43 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> On Sat, Oct 19, 2019 at 2:22 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
>>
>> Hygiene is also a concern when identifiers are used as markers. This
>> happens when they are record field names in record-type definitions.
>> It also when they are used as keywords in `syntax-rules' macros (i.e.
>> when they occur in the list of identifiers that are to be matched
>> literally in `syntax-rules'). For example, `else' and `=>' are bound
>> to some syntactic value by `(scheme base)', and when the transformer
>> associated to `cond' expands such a `cond' form, it checks against the
>> binding and not the name (see the definition of `free-identifier=?' in
>> the R6RS).
>
>
> These instances are reasonable and I'm not opposing it at all.  I just think keywords are different.
> Actually, keyword argument markers don't even need to be symbols or identifiers; they can be any
> literal data, as far as they can be compared both at compile time and runtime (preferably, by eq?).
> Runtime comparison is necessary, since keyword-value list can be (and need to be) passed around
> via rest arguments.
>
> What do you say about necessity of renaming conflicting keywords from different libraries?  Or
> am I missing something and worring nonexistent problem?

Think of a procedure `loggable' on may want to implement with keyword
arguments. `loggable' shall take a procedure `f' and return a new
procedure `g', which shall have the same interface as `f' except that
`g' takes an extra keyword argument, say `logger:'. When `g' is called
without the `logger:' argument, it shall foward the call to `f''.
However, when the `logger.' argument is provided, `g' shall log to
this logger that it is calling `f' before it is doing the actual call.

As `f' may already be a procedure taking keyword arguments, it is here
where hygiene is helpful because the symbol (!) `logger:' may clash
with an already existing argument to `f'.

Scheme is not CL and has hygienic macros. Its keyword-system shouldn't
be less elegant and beautiful than its `syntax-rules' system.