guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case-lambda* question


From: Daniel Hartwig
Subject: Re: case-lambda* question
Date: Thu, 15 Nov 2012 09:22:14 +0800

On 14 November 2012 18:20, Daniel Llorens <address@hidden> 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”.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]