今, fというファイルをコンパイルしているとする. f内で,
defun, defmethod, defclass,
deftype などを用いて定義された関数, メソッドや型は, f内の残りにお
いて使用(参照)できる. したがって例えば,
(defun f (x) (declare (fixnum x) (reply-type fixnum)) (+ x 1)) (defun g (x) (declare (fixnum x) (reply-type fixnum)) (+ (f x) 1))は許されるが,
(defun g (x) (declare (fixnum x) (reply-type fixnum)) (+ (f x) 1)) (defun f (x) (declare (fixnum x) (reply-type fixnum)) (+ x 1))は許されない. 後者に関してはコンパイラは,
Expand Error: Procedure f not declaredというエラーを出す.
型の定義と使用に関しても同様の原則が成り立つ. 例えば,
(deftype 2d-point () (2d-point real real)) (deftype 2d-point-tree () (leaf 2d-point) (node 2d-point-tree 2d-point-tree))は正しいがこの二つを逆の順番で定義すると,
Syntax Error: Unknown type 2d-pointというエラーを受けとる.