On Nov 15, 2012, at 02:22, Daniel Hartwig wrote: > On 14 November 2012 18:20, Daniel Llorens <daniel.llor...@bluewin.ch> wrote: >>> When the doc. states keyword arguments do not contribute to the >>> success of a match, it refers only to keyword arguments in the >>> case-lambda clause, not at the call site. This makes sense, otherwise >>> it would inhibit writing functions that detect keywords internally >>> from their rest arguments. >> >> Do you mean something like this? >> >> (define* (f a #:key x) x) >> (define (g . args) (apply f args)) >> (g 0) -> #f >> (g 0 #:x #t) -> #t >> >> i.e. g must accept being called with 3 'arguments' so that it can forward >> the keyword args. > > I was thinking of: > > (define f > (case-lambda* > ((a . rest) > (if (memq #:x rest) … > > where #:x is picked up from inside rest. > > Based on the other error, I'd say that any case-lambda* with keyword > arguments is matched with a rest argument instead, i.e. “a #:key x” is > treated as “a . rest”.
Ok, I think I see how (define f (case-lambda* ((x #:optional y) 1) ((x #:key y) 2) ((x y #:key z) 3))) (f #:y 2) works. x is #:y and y is 2. However, this should go to (x y #:key z) and it doesn't: (f 1 2 #:z 3) -> Odd length of keyword argument list while given (define g (case-lambda* ((a #:key x) 1) ((a b c #:key x) 3))) this should match (a b c #:key x) and it doesn't. (g 1 2 3) - > Invalid keyword Or maybe we should say that (g 1 2 3) shouldn't match (a #:key x)? Either way, I'll file these as a bug. Thanks, Daniel