I'm trying to write some portable (i.e., ANSI compatible) loading
code, and have the following forms in a file (inet-init.lisp).
(defvar *inet-root*
(make-pathname :directory (pathname-directory *load-pathname*)))
(unless (ignore-errors (logical-pathname-translations "inet"))
(setf (logical-pathname-translations "inet")
`(("**;*.*.*" ,*inet-root*))))
(unless (find-package "ASD")
(load "inet:Utilities;A-Simple-Defsystem;a-simple-defsystem"))
Under Windows, the file structure looks like this:
c:\work\il\inet-init.lisp
c:\work\il\Utilities\A-Simple-Defsystem\a-simple-defsystem.lisp
These forms do the right thing under Allegro Common Lisp, but CLISP
says:
*** - PARSE-NAMESTRING: syntax error in filename
"inet:Utilities;a-simple-defsystem;a-simple-defsystem" at position 4
And (directory "inet:*.*") causes a similar error.
Is it my code, or CLISP which is doing the wrong thing?
··········@inetmi.com (Will Fitzgerald) writes:
> I'm trying to write some portable (i.e., ANSI compatible) loading
> code, and have the following forms in a file (inet-init.lisp).
>
> (defvar *inet-root*
> (make-pathname :directory (pathname-directory *load-pathname*)))
To be portable, you should use:
(make-pathname :name nil :type nil :version nil
:defaults *load-truename*)
or
(make-pathname :name nil :type nil :version nil
:host (pathname-host *load-truename* :case :common)
:device (pathname-device *load-truename* :case :common)
:directory (pathname-device *load-truename* :case :common)
:case :common)
MAKE-PATHNAME will always default the host so you might as well control it.
It's bad to default the host and dir without defaulting device, too. This
would lose on TOPS-20, for example, where MY-TOPS-20:SRC:<FOO> wants to
have all three parts copied, or you usually end up with MY-TOPS-20:PS:<FOO>
which isn't what you want.
When dealing with any of the 6 component slots (:host, :device, :directory,
:name, :type, :version), to be portable, you must use :case :common for
all accesses with a pathname-xxx accessor and all stores with a MAKE-PATHNAME.
If you fail to, you will use :case :local, and this will not always do the
right thing. (I think it might in this particular special case work to use
:case :local but it's not a consistent rule to use generally unless you want
to learn more about pathnames than most people care to.)
> (unless (ignore-errors (logical-pathname-translations "inet"))
> (setf (logical-pathname-translations "inet")
> `(("**;*.*.*" ,*inet-root*))))
>
> (unless (find-package "ASD")
> (load "inet:Utilities;A-Simple-Defsystem;a-simple-defsystem"))
>
> Under Windows, the file structure looks like this:
>
> c:\work\il\inet-init.lisp
> c:\work\il\Utilities\A-Simple-Defsystem\a-simple-defsystem.lisp
>
> These forms do the right thing under Allegro Common Lisp, but CLISP
> says:
>
> *** - PARSE-NAMESTRING: syntax error in filename
> "inet:Utilities;a-simple-defsystem;a-simple-defsystem" at position 4
>
> And (directory "inet:*.*") causes a similar error.
>
> Is it my code, or CLISP which is doing the wrong thing?
Did you try using uppercase "INET"? I don't have CLISP handy so can't
say, but some implementations erroneously assume host names have to be
uppercase and they may case-translate your input. So you may have (through
SETF) defined an "inet" host and then tried to parse an "INET" host. I
think they should case-fold the host for lookup. File system hosts are
not generally cased.
Btw, though it doesn't seem to be the case here, **; refers to
:wild-inferiors but Unix natively doesn't support a "**" notation, so
unless Lisp simulates it, you're going to lose on some Unix systems.
If you want to be really compatible, you will individually map *; to */
*;*; to */*/ and so on down to some nesting depth that makes you happy.
There may be other issues in here as well, but that's at least a few things
to look for.
> * In message <····························@posting.google.com>
> * On the subject of "Fun with logical pathnames"
> * Sent on 30 Nov 2001 15:06:46 -0800
> * Honorable ··········@inetmi.com (Will Fitzgerald) writes:
>
> *** - PARSE-NAMESTRING: syntax error in filename
> "inet:Utilities;a-simple-defsystem;a-simple-defsystem" at position 4
(setq custom:*parse-namestring-ansi* t)
see <http://clisp.cons.org/impnotes.html#parsename> and
<http://clisp.cons.org/impnotes.html#ansi>.
--
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
The difference between theory and practice is that in theory there isn't any.