Am Fr., 6. März 2020 um 14:52 Uhr schrieb John Cowan <xxxxxx@ccil.org>:


On Fri, Mar 6, 2020 at 2:34 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

There are other common macros names like "when" or "unless" that would make sense as keyword names as well.

That's the same argument that CL people use against Lisp-1s: that because there is a standard procedure named 'list', one is precluded from having an argument or local variable with that name.  (Of course this is only true if the procedure is actually needed in the local context.)

Perhaps more on point is something like this:

 (let ((else #f)) (cond ((= 1 0) #f) (else 77)))

I suspect that many people will be surprised by what is returned.

While it is certainly not wrong what you say, John, I fail to see what it has to do with the issue raised.

In a situation like

(define (f list) ...)

you can simply rename `list' so that you can use the `list' procedure in `...'. It won't change the calling protocol of the procedure.

On the other hand, when you have

(lambda/kw (x y (when))
  ...)

you cannot rename `when' in the argument list because this would rename the keyword as well (and would change the calling protocol of the procedure).

The problem here is really that `lambda/kw' conflates identifiers and symbols. `when' is interpreted as a symbol for the calling protocol and as an identifier for the binding of the keyword argument in `...'.

For most use cases, this is convenient but for the sake of clarity, the above form should really be an abbreviation of a general form

(lambda/kw (x y (when when))
  ...)

Here, the first `when' is the identifier to which the location of the keyword argument will be bound and the second is the keyword name (or vice versa, depending on what you think makes more sense).

The "conflating" form of `lambda/kw' is furthermore dangerous when used in macros: Assume `(lambda/kw (x y (z)) ... w ...)' is in the template of a macro where `z' and `w' are macro parameters. For the macro writer everything looks fine but it will make boom when the macro user supplies the same macro parameter for `z' and `w'.