SBCL Preliminary Declaration: Possibly?

I write code in SBCL, and ordering my functions causes the following warnings to appear when uploading files to REPL:

;caught STYLE-WARNING:
    undefined function: FOO

Where FOOis the function symbol. This is explained only by how they are ordered in my file, because a function is defined FOO, but not before the part of the code that issues this warning.

Now, in Clojure, which is Lisp that I'm familiar with, I have a form declarethat allows me to make declarations to avoid such a problem. Is there something similar for SBCL / Common Lisp in general?

+4
source share
2 answers

Here is what I found in the manual, section 4.1.1:

CL-USER> (defun foo (x) (bar x))
; in: DEFUN FOO
;     (BAR X)
; 
; caught STYLE-WARNING:
;   undefined function: BAR
; 
; compilation unit finished
;   Undefined function:
;     BAR
;   caught 1 STYLE-WARNING condition
FOO
CL-USER> (declaim (sb-ext:muffle-conditions style-warning))
; No value
CL-USER> (defun baz (y) (quux y))
BAZ

, .

, SBCL REPL: . lisp " " :

(defun foo (x) (bar x))
(defun bar (y) (baz y))

SBCL baz, bar. SBCL ?

+1

'(declaim (ftype...))' :

(declaim (ftype (function (integer list) t) ith))

(defun foo (xs)
  (ith 0 xs))

(defun ith (n xs)
  (nth n xs))

"foo" "i" , .

http://www.lispworks.com/documentation/HyperSpec/Body/d_ftype.htm

+1

Source: https://habr.com/ru/post/1540325/


All Articles