Compiles a Lisp source file if it is newer than the corresponding fasl file.
hcl
compile-file-if-needed input-pathname &key output-file load &allow-other-keys => output-truename, warnings-p, failure-p
| input-pathname⇩ |
A pathname designator. |
| output-file⇩ |
A pathname designator. |
| load⇩ |
A generalized boolean. |
| output-truename |
A pathname or nil. |
| warnings-p |
A generalized boolean. |
| failure-p |
A generalized boolean. |
The function compile-file-if-needed compares the file-write-date of the source file named by input-pathname with the file-write-date of the appropriate fasl file (as computed by compile-file-pathname from input-pathname and output-file). compile-file-if-needed also checks if the fasl file was compiled by the same version of LispWorks as the image in which compile-file-if-needed is called.
If the fasl file does not exist or is older than input-pathname or was compiled by another version, then compile-file is called with input-pathname, output-file, load and any other arguments passed., and the values returned are those returned from compile-file.
Otherwise, if load is true compile-file-if-needed loads the fasl file and returns nil, and if load is nil it simply returns nil.
CL-USER 19 > (compile-file-if-needed "H:/tmp/foo.lisp"
:output-file
"C:/temp/")
;;; Compiling file H:/tmp/foo.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 0
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is off
;;; Source file recording is on
;;; Cross referencing is off
; (TOP-LEVEL-FORM 1)
; (TOP-LEVEL-FORM 2)
; (TOP-LEVEL-FORM 3)
; FOO
; BAR
#P"C:/temp/foo.ofasl"
NIL
NIL
CL-USER 20 > (compile-file-if-needed "H:/tmp/foo.lisp"
:output-file
"C:/temp/"
:load t)
; Loading fasl file C:\temp\foo.ofasl
NIL
LispWorks® User Guide and Reference Manual - 18 Feb 2025 15:32:21