fasl-file-valid-p
From: Sam Steingold (sds_at_gnu.org)
Date: 11/29/04
- Next message: Peter Seibel: "Re: What do Users really want?"
- Previous message: William Bland: "Re: C++ sucks for games.... oh really?"
- Next in thread: Daniel Barlow: "Re: fasl-file-valid-p"
- Reply: Daniel Barlow: "Re: fasl-file-valid-p"
- Reply: Svein Ove Aas: "Re: fasl-file-valid-p"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Nov 2004 12:51:05 -0500
Build tools, like defsystem or asdf, have to determine whether a file
needs to be recompiled. Obviously, when the .fasl is older than the
.lisp, recompilation is in order.
Alas, there are other situations when this might be necessary, e.g.,
when the implementation changes the FASL format or when two
implementations use the same name for their FASL files
(are there such cases?)
Proposal:
function (FASL-FILE-VALID-P file-name) => valid-p
return T if the file is a valid FASL file for this implementation and
NIL otherwise.
E.g.,
(fasl-file-valid-p "foo.lisp") ==> NIL
(fasl-file-valid-p (compile-file "foo.lisp")) ==> T
the trivial implementation:
(defun fasl-file-valid-p (file-name)
(not (nth-value 1 (ignore-errors (load file-name)))))
is wrong because,
1. LOAD may fail even though the file is valid:
even when "foo.lisp" contains "(error)",
(fasl-file-valid-p (compile-file "foo.lisp"))
should still return T
2. this is not side-effect-free, i.e., this may define new functions and
macros (or, worse yet, redefine some existing functions and macros or
execute some malicious code).
Cost to implementors: something like this:
#+clisp
(defun fasl-file-valid-p (file-name)
(with-open-file (in file-name :direction :input :if-does-not-exist nil)
(and in
(let ((line (read-line in nil nil)))
(and line
(string= line "(SYSTEM::VERSION " :start1 0
:end1 #.(length "(SYSTEM::VERSION "))
(null (nth-value 1 (ignore-errors
(eval (read-from-string line))))))))))))
Comments?
-- Sam Steingold (http://www.podval.org/~sds) running w2k <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.honestreporting.com> Binaries die but source code lives forever.
- Next message: Peter Seibel: "Re: What do Users really want?"
- Previous message: William Bland: "Re: C++ sucks for games.... oh really?"
- Next in thread: Daniel Barlow: "Re: fasl-file-valid-p"
- Reply: Daniel Barlow: "Re: fasl-file-valid-p"
- Reply: Svein Ove Aas: "Re: fasl-file-valid-p"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|