Morning all.

I get your point and I had noticed the definitions of the error cases. At the same time, in which valid scenario could the write time of a file not be determined and therefore lead file-write-date to return nil?

FYI, I came across that question when I tried to execute with SBCL a piece of code written by Peter Norvig in Paradigm of AI Programming (http://www.norvig.com/paip/README.html). His auxfns.lisp (http://www.norvig.com/paip/auxfns.lisp) contains this declaration:
(defun load-paip-file (file)
  "Load the binary file if it exists and is newer, else load the source."
  (let* ((src (paip-pathname file :lisp))
	 (src-date (file-write-date src))
	 (bin (paip-pathname file :binary))
	 (bin-date (file-write-date bin)))
    (load (if (and (probe-file bin) src-date bin-date (>= bin-date src-date))
	      bin
	    src))))
The copyright statement mentions 1991. Even though it may look strange to probe the "bin" file instead of just checking that bin-date is not nil, it seems his thinking when using that (pre-ANSI?) CL was that file-write-date would not lead to an error when the targeted file does not exist.

Anyway I modified the code to make it work with SBCL.

Cheers,
--Christian


From: edgar <edgar-rft@web.de>
To: Christian Wagner <christian_r_wagner@yahoo.co.uk>
Cc: "sbcl-bugs@lists.sourceforge.net" <sbcl-bugs@lists.sourceforge.net>
Sent: Tuesday, 2 July 2013, 22:44
Subject: Re: [Sbcl-bugs] [SBLC 1.1.3] file-write-date failure when file does not exist

Am Tue, 2 Jul 2013 13:12:34 +0100 (BST)
schrieb Christian Wagner <christian_r_wagner@yahoo.co.uk>:

> Hi.
>
> In SBLC 1.1.3 running on Mac OS/X 10.6.8 calling FILE-WRITE-DATE on a
> file which doesn't exist fails because of
> a SB-IMPL::SIMPLE-FILE-PERROR.
>
> Following LispWorks's CL HyperSpec
> (http://www.lispworks.com/documentation/HyperSpec/Body/f_file_w.htm#file-write-date)
> I was expecting NIL to be returned.

Please read again
http://www.lispworks.com/documentation/HyperSpec/Body/f_file_w.htm#file-write-date,
where is written:

Exceptional Situations:

An error of type file-error is signaled if the file system cannot
perform the requested operation.

- edgar





--
The author of this email does not necessarily endorse the following
advertisements, which are the sole responsibility of the advertiser: