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.
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)