[pro] CDR proposal: compiled-file-p
Pascal Costanza
pc at p-cos.net
Tue May 15 17:41:10 UTC 2012
Hi,
I am one of the CDR editors, but I haven't seen your email. I have double-checked the email forwarding just now, and it seems to work. I cannot check anymore whether your email accidentally landed in my spam folder, because it has a retention period of a week.
Could you try to resend your CDR proposal, and then send a notification to my private address as well? If I then still don't receive your proposal via the editors email address, I have to dig deeper to try to see where the problem is.
In any case, I will process the CDR proposal next weekend.
Thanks a lot,
Pascal
On 15 May 2012, at 17:54, Sam Steingold wrote:
> In 2004 I submitted a CLRFI which was then accepted as CLRFI-2.
> It specified a new function COMPILED-FILE-P which was supposed to be
> useful for system construction utilities, e.g., asdf:
>
> Function
> (compiled-file-p file-name) ==> valid-p
>
> Returns
> true if the file appears to be a valid compiled file
> (i.e., exists, is readable, and the contents appears to be
> valid for this implementation),
> false otherwise.
>
> Implementations are required to inspect the contents
> (e.g., checking just the pathname type is not sufficient).
> Although the completeness of the inspection is not required,
> this function should be able to detect,
> e.g., file format changes between versions.
>
> I re-submitted the spec to the CDR editors a week ago.
> No response so far.
>
> The detailed html spec is attached.
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
>
> <head>
> <title>Function COMPILED-FILE-P</title>
> <meta name="author" value="Sam Steingold"/>
> </head>
> <body>
>
> <h1>Function <code>COMPILED-FILE-P</code></h1>
>
> <h2>Author</h2>
>
> <p>Sam Steingold</p>
>
> <h2>Related</h2>
>
> <p>ANSI Common Lisp standard function <code>compile-file</code>.</p>
>
>
> <h2>Abstract</h2>
>
> <p>A facility to determine whether a file is a valid compiled file for
> the specific implementation.</p>
>
>
> <h2>Rationale</h2>
>
> <p>Build tools, like <code>defsystem</code> or <code>asdf</code>,
> have to determine whether a file needs to be recompiled.</p>
> <p>Obviously, when the compiled file is older than the
> source file, recompilation is in order.</p>
> <p>Alas, there are other situations when this might be necessary, e.g.,
> when the implementation changes the compiled file format or when two
> implementations use the same name for their compiled files
> (<code>.fasl</code> is used by both <code>SBCL</code> and <code>ACL</code>).
> </p>
>
>
> <h3>Current Practice</h3>
>
> <p>Implementation-dependent.</p>
>
> <h3>Cost of adoption</h3>
>
> <p>Probably tiny: an implementation must be able to check for compiled
> file validity, so all it takes is to export the necessary
> functionality, e.g.:</p>
>
> <pre id="compiled-file-p-clisp">
> #+clisp
> (defun compiled-file-p (file-name)
> (with-open-file (in file-name :direction :input :if-does-not-exist nil)
> (and in (char= #\( (peek-char nil in))
> (let ((form (ignore-errors (read in nil nil))))
> (and (consp form)
> (eq (car form) 'SYSTEM::VERSION)
> (null (nth-value 1 (ignore-errors (eval form)))))))))
> </pre>
>
> <h3>Cost of non-adoption</h3>
>
> <p>Users will suffer random errors when trying to load invalid binary
> files.</p>
>
>
> <h2>Specification</h2>
>
> <p>Function</p><pre>
> (compiled-file-p file-name) ==> valid-p
> </pre>
>
> <p>Returns</p><dl>
> <dt><code>true</code></dt><dd>if the file appears to be a valid compiled file
> (i.e., exists, is readable, and the contents appears to be
> valid for this implementation),</dd>
> <dt><code>false</code></dt><dd>otherwise.</dd></dl>
>
> <p>Implementations are required to inspect the contents
> (e.g., checking just the pathname type is not sufficient).
> Although the completeness of the inspection is not required,
> this function should be able to detect,
> e.g., file format changes between versions.</p>
>
> <h3>Exceptional situations</h3> <ul>
> <li>signals an error of type <code>type-error</code>
> when the argument is not a <em>pathname designator</em>.</li>
> </ul>
>
> <h3>Examples</h3>
>
> <pre>
> (compiled-file-p "foo.lisp") ==> NIL
> (compiled-file-p (compile-file "foo.lisp")) ==> T
> </pre>
>
>
> <h2>Reference Implementation</h2>
>
> <p>See <a href="#compiled-file-p-clisp">above</a>.</p>
>
>
> <h2>History</h2>
>
> <p>This used to be <strong>CLRFI-2</strong> (in 2004).</p>
>
> <h2>Notes</h2>
>
> <p>The trivial implementation:</p>
> <pre>
> (defun compiled-file-p (file-name)
> (not (nth-value 1 (ignore-errors (load file-name)))))
> </pre>
> <p>is wrong because,</p>
> <ol>
> <li><code>load</code> may fail even though the file is valid:
> even when <code>foo.lisp</code> contains calls to <code>error</code>,<pre>
> (compiled-file-p (compile-file "foo.lisp"))
> </pre>should still return <code>T</code>.</li>
> <li>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).</li></ol>
> </body>
> </html>
>
>
> --
> Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
> http://www.childpsy.net/ http://mideasttruth.com http://ffii.org
> http://www.memritv.org http://jihadwatch.org http://camera.org http://memri.org
> You cannot fire me. Slaves are not fired. Slaves are sold.
> _______________________________________________
> pro mailing list
> pro at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro
--
Pascal Costanza
More information about the pro
mailing list