From: ··············@yahoo.com
Subject: Pathname translations to types without type specification.
Date: 
Message-ID: <7766ks$37q$1@nnrp1.dejanews.com>
Just curious if this is possible. I can set up pathname translations so that I
can specify logical pathnames like

"lisp:source;foo.lisp" which maps to:
"/home/rmiles/code/lisp/source/foo.lisp"

and

"lisp:compiled;foo.fasl" which maps to:
"/home/rmiles/code/lisp/source/compiled/foo.fasl"

but since the *.lisp type in practice is always used with
lisp:source;whatever.lisp and the *.fasl is always used with
lisp:compiled;whatever.fasl, they are redundant, so it would be cool if it
were possible to translate

"lisp:source;foo" to:
"/home/rmiles/code/lisp/source/foo.lisp"

and

"lisp:compiled;foo to:
"/home/rmiles/code/lisp/source/compiled/foo.fasl"

Then you could do stuff like:

(compile-file "lisp:source;foo")
(load "lisp:compiled;foo")

Which would be very cool, but it seems impossible to map a name without a type
specified to the same name with a default type. Setting up a translation like:

(setf (logical-pathname-translations "lisp")
  '(("source;**;*"   "/home/rmiles/code/lisp/source/*.lisp")
    ("source;**;*.*" "/home/rmiles/code/lisp/source/*.lisp")))

Gives you this behavior:

USER(5): (translate-logical-pathname "lisp:source;foo.lisp")
#p"/home/rmiles/code/lisp/source/foo.lisp"                ; so far so good
USER(6): (translate-logical-pathname "lisp:source;foo.cl")
#p"/home/rmiles/code/lisp/source/foo.lisp"                ; so far so good
USER(7): (translate-logical-pathname "lisp:source;foo.")
#p"lisp:source;foo."                                      ; hmmmmm
USER(8): (translate-logical-pathname "lisp:source;foo")
#p"/home/rmiles/code/lisp/source/foo"                     ; I wanted foo.lisp

I tried doing some weird things like backquoting the translations list and
then setting some translations to translate to other logical pathnames which
in turn would be translated to a namestring but this still didn't do what I
wanted and sometimes infinity looped.

Is there any way to do what I want?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

From: Christopher R. Barry
Subject: Re: Pathname translations to types without type specification.
Date: 
Message-ID: <87sodltddl.fsf@2xtreme.net>
··············@yahoo.com writes:

> Just curious if this is possible. I can set up pathname translations so that I
> can specify logical pathnames like
> 
> "lisp:source;foo.lisp" which maps to:
> "/home/rmiles/code/lisp/source/foo.lisp"
> 
> and
> 
> "lisp:compiled;foo.fasl" which maps to:
> "/home/rmiles/code/lisp/source/compiled/foo.fasl"

[...]

> Is there any way to do what I want?

Right now I'm set up so that if I put a file named foo.lisp in
/home/cbarry/lisp then in both ACL and CMUCL I can do

USER(1): (compile-file "lisp:code;foo")
;;; Compiling file lisp:code;foo.lisp (/home/cbarry/lisp/foo.lisp)
;;; Writing fasl file lisp:code;foo.fasl
;;;   (/home/cbarry/lisp/acl-compiled/foo.fasl)
;;; Fasl write complete
#p"lisp:code;foo.fasl"
T
NIL
USER(2): (load "lisp:code;foo")
; Fast loading lisp:code;foo.fasl (/home/cbarry/lisp/acl-compiled/foo.fasl)
T

And in CMUCL

* (compile-file "lisp:code;foo")
Python version 1.0, VM version Intel x86 on 08 JAN 99 05:45:18 pm.
Compiling: /home/cbarry/lisp/foo.lisp 08 JAN 99 05:40:13 pm

Converted FOO.
Compiling DEFUN FOO: 
Byte Compiling Top-Level Form: 

LISP:CODE;FOO.FASL written.
Compilation finished in 0:00:00.

#p"/home/cbarry/lisp/cmucl-compiled/foo.fasl"
NIL
NIL
* (load "lisp:code;foo")
; Loading #p"/home/cbarry/lisp/cmucl-compiled/foo.fasl".
T

To set this up for ACL, put something like this in #p"sys:hosts.cl" (likely
/usr/local/acl5/hosts.cl):

"lisp"      '("code;**;*.fasl"   "/home/cbarry/lisp/acl-compiled/")
            '("code;**;*.*"      "/home/cbarry/lisp/")

And to get this working in CMUCL, put something like this in your
~/.cmucl-init.lisp:

(setf (logical-pathname-translations "lisp")
      '(("code;**;*.fasl"   "/home/cbarry/lisp/cmucl-compiled/")
	("code;**;*.*"      "/home/cbarry/lisp/")))

Keeping the fasl's for CMUCL and ACL seperated is convenient and not
putting them in the same directory as your source keeps things nice
and uncluttered.

Christopher
From: R. Toy
Subject: Re: Pathname translations to types without type specification.
Date: 
Message-ID: <3696D8B3.6B617660@mindspring.com>
Christopher R. Barry wrote:
> 
> Right now I'm set up so that if I put a file named foo.lisp in
> /home/cbarry/lisp then in both ACL and CMUCL I can do
> 
[snip ACL example]
> 
> And in CMUCL
> 
> * (compile-file "lisp:code;foo")
> Python version 1.0, VM version Intel x86 on 08 JAN 99 05:45:18 pm.
> Compiling: /home/cbarry/lisp/foo.lisp 08 JAN 99 05:40:13 pm
[snip]
> LISP:CODE;FOO.FASL written.
> Compilation finished in 0:00:00.
> 
> #p"/home/cbarry/lisp/cmucl-compiled/foo.fasl"
> NIL
> NIL
> * (load "lisp:code;foo")
> ; Loading #p"/home/cbarry/lisp/cmucl-compiled/foo.fasl".
> T
> 

I believe your examples work because in CMUCL, compile-file trys several
possible extensions if the specified file does not exist.  First for
logical pathnames, it appends the type "LISP".  Then tries the path
itself, then with types "lisp" and finally "dylan".  (See
compiler/main.lisp.)

For load, if the file does not exist, it tries loading a file with
various extensions like "LISP", "lisp", "cl", "lsp", and then the fasl
types.  Look at lisp::*load-source-types* and lisp::*load-object-types*.

I suppose ACL does something similar.

Ray
-- 
---------------------------------------------------------------------------
----> Raymond Toy	····@mindspring.com
                        http://www.mindspring.com/~rtoy
From: Sunil Mishra
Subject: Re: Pathname translations to types without type specification.
Date: 
Message-ID: <efyk8yw5ld2.fsf@whizzy.cc.gatech.edu>
··············@yahoo.com writes:

> lisp:compiled;whatever.fasl, they are redundant, so it would be cool if it
> were possible to translate
> 
> "lisp:source;foo" to:
> "/home/rmiles/code/lisp/source/foo.lisp"
> 
> and
> 
> "lisp:compiled;foo to:
> "/home/rmiles/code/lisp/source/compiled/foo.fasl"
> 
> Then you could do stuff like:
> 
> (compile-file "lisp:source;foo")
> (load "lisp:compiled;foo")
> 
> Which would be very cool, but it seems impossible to map a name without a type
> specified to the same name with a default type. Setting up a translation like:
> 
> (setf (logical-pathname-translations "lisp")
>   '(("source;**;*"   "/home/rmiles/code/lisp/source/*.lisp")
>     ("source;**;*.*" "/home/rmiles/code/lisp/source/*.lisp")))

Try:

CL-USER 32 > (setf (logical-pathname-translations "lisp")
      `(("source;**;*" ,(make-pathname :directory '(:absolute "home" "rmiles" "code" "lisp"
						    "source" :wild-inferiors)
				       :name :wild
				       :type "lisp"))
	("source;**;*.*" ,(make-pathname :directory '(:absolute "home" "rmiles" "code" "lisp"
						      "source" :wild-inferiors)
					 :name :wild
					 :type "lisp"))))
(("source;**;*" #P"/home/rmiles/code/lisp/source/**/*.lisp") ("source;**;*.*" #P"/home/rmiles/code/lisp/source/**/*.lisp"))

CL-USER 33 > (translate-logical-pathname "lisp:source;foo")
#P"/home/rmiles/code/lisp/source/foo.lisp"

CL-USER 34 > (translate-logical-pathname "lisp:source;foo.bar")
#P"/home/rmiles/code/lisp/source/foo.lisp"

*** Note that if you want this to translate to foo.bar, you will have to
*** remove the second pathname translation for source.

CL-USER 35 > (translate-logical-pathname "lisp:source;bar;foo.bar")
#P"/home/rmiles/code/lisp/source/bar/foo.lisp"

Sunil