Am Mo., 16. März 2020 um 21:27 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
On Mon, Mar 16, 2020 at 4:04 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

Assume that `bar' is a procedure taking a variable number of arguments and an optional keyword argument with the keyword `foo'.  What is the meaning of the following?

(bar ':foo x)

(1) A call to `bar' with two ordinary arguments, namely the keyword value `:foo' and the evaluation of `x'.
(2) A call to `bar' with no ordinary arguments but with the optional keyword argument with the keyword `foo' and the value, which is the evaluation of `x'.

If the answer is (1), how can you get (2).  And if the answer is (2), how can you get (1)?

My brain is so infected by Common Lisp that I might fail to see other models.
Here's a definition of bar that takes a keyword argument foo and two optional arguments in Gauche syntax:

(define (bar :optional x y :key foo) (list x y foo))

(bar) => (#<undef> #<undef> #<undef>)    ; #<undef> is the default value
(bar 1) => (1 #<undef> #<undef>)
(bar 1 2) => (1 2 #<undef>)
(bar 1 2 :foo 3) => (1 2 3)
(bar :foo 3) => (:foo 3 #<undef>)  ; of course you want this behavior, otherwise you can't pass :foo to x.

How do you call `bar' in Common Lisp's/Gauche's model so that `x' and `y' do not receive any values but `foo' receives the value `3'?

How would you handle a procedure that can arbitrarily many positional arguments and keyword arguments?

With Kawa's model this is easily doable; with CL's/Gauche's model I don't see how.

The optimization possibilities Per mentioned don't work with CL's model, which just looks like an ordinary plist argument in disguise.
Marc
 

In Common Lisp,

(defun bar (&optional x y &key foo) (list x y foo))

(bar) => (nil nil nil)
(bar 1) => (1 nil nil)
(bar 1 2) => (1 2 nil)
(bar :foo 3) => (:foo 3 nil)
(bar 1 2 :foo 3) => (1 2 3)