Lisp HUG Maillist Archive

defadvice bug with tail calls?

Looks to me like the DEFADVICE facility doesn't work if the compiler
thinks it can eliminate a tail call - even if I haven't requested any
optimizations. (See example below.)

Is this a bug or did I miss something in the docs?

Thanks,
Edi.



  CL-USER 1 > (defun foo (n) (if (= n 0) 0 (foo (1- n))))
  FOO

  CL-USER 2 > (defadvice (foo foo :around) (n) (print n) (call-next-advice n))
  T

  CL-USER 3 > (foo 3)

  3
  2
  1
  0
  0

  CL-USER 4 > (compile 'foo)
  FOO
  NIL
  NIL

  CL-USER 5 > (foo 3)

  3
  0

  CL-USER 6 > (defun foo (n) (if (= n 0) 0 (identity (foo (1- n)))))
  FOO

  CL-USER 7 > (compile 'foo)
  FOO
  NIL
  NIL

  CL-USER 8 > (foo 3)

  3
  2
  1
  0
  0

  CL-USER 9 >


Re: defadvice bug with tail calls?

Unable to parse email body. Email id is 1066

Updated at: 2020-12-10 09:00 UTC