clasp
clasp copied to clipboard
Recursive functions give compiler warning: Style warning: Undefined function
COMMON-LISP-USER> (defun fibonacci (n)
(cond ((< n 0) (error "Please pass a positive argument ~a~%" n))
((= n 0) 0)
((= n 1) 1)
(t (+ (fibonacci (1- n))(fibonacci (- n 2))))))
;;; Style warning: Undefined function FIBONACCI
;;; at -unknown-file- filepos: 0 lineno: 0
FIBONACCI
The call itself works fine. Pretty sure this is a regression, but don't know how to prove that
Specifically they give a warning in the REPL, i.e. if they are compiled. The file compiler doesn't seem to complain about it, presumably because before compiling the definition it hits the register-global-function-def in the eval-when. Not sure how to fix this. If it's a regression, it's only because we used to not signal any warnings.
sbcl's mechanism for avoiding this appears to be sb-int:named-lambda, which not only gives a function a name, but makes that name bound to the function in its body.