[CM] define* and :rest bug

Christos Vagias chris.actondev at gmail.com
Fri Jul 30 10:29:10 PDT 2021


Another, better, example:
Imagine you want to write something like apply,
but which accepts some optional argument (let's say debug)

(define* (my-apply f :rest args (debug #f))
  (when debug
    (format *stderr* "passed args: ~A\n" args))
  (apply f args))

(my-apply + 1 2 3) ;; debug is 2, not #f

(my-apply + 1 2 3 :debug #t) ;; args are (1 2 3 :debug #t),  debug is 2
;; error: + argument 2, :debug, is a symbol but should be a number

(my-apply :debug #t + 1 2 3 ) ;; error: parameter set twice, debug in
(:debug #t + 1 2 3)

On Fri, 30 Jul 2021 at 17:21, <bil at ccrma.stanford.edu> wrote:

> I'm not sure I understand the desired functionality.
> The arguments after the rest argument should be like
> auxiliary arguments in CL (or whatever they are called) --
> basically variable declarations?  Ah, I looked it up --
> &aux in the CL lambda list -- I never used those!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20210730/7a5bb3f6/attachment.html>


More information about the Cmdist mailing list