[CM] define* and :rest bug

Christos Vagias chris.actondev at gmail.com
Fri Jul 30 14:43:22 PDT 2021


Good point!
Well the :rest that could be before the other arguments got my hopes
up that I could mix named arguments and the rest.
But,

A perhaps possible solution would be to give priority to "rest" when
the lambda* arguments have a default value, like so:
((lambda* (a (b "the-b") . rest) (list 'a a 'b b 'rest rest)) '(0 1
2)) ;; (a 0 b "the-b" rest (1 2))

In any case in my specific usecase instead of relying on :rest, I
named the argument and I'm passing a list. Perhaps that's better and
more clear in the code as well.

I will look into CL and what "rest" and &aux are there. I guess some
old mailing list might have some discussion on the topic.

Thanks Bil!


On Fri, 30 Jul 2021 at 21:46, <bil at ccrma.stanford.edu> wrote:
>
> But then what would
>
>    (my-apply + 1 2 3 :debug #t 4 5 6)
>
> expect? Perhaps this would be usable:
>
> (define-macro* (my-apply debug :rest rest)
>    `(if (not (boolean? ,debug))
>         (apply ,debug ',rest)
>         (begin
>          (when ,debug
>            (format *stderr* "debugging\n"))
>          (apply ,(car rest) ',(cdr rest)))))
>
>
>


More information about the Cmdist mailing list