From: ············@gmail.com
Subject: so, which of the lisps works?
Date: 
Message-ID: <1110280194.720486.325480@o13g2000cwo.googlegroups.com>
I am trying to make relative paths work. In all.lisp, I have

(let ((*default-pathname-defaults* *load-pathname*))

and hope that all files will be relative from the all.lisp's directory
when I invoke

(load "all")

This almost works with most implementations (lisworks, openmcl,clisp).
However, it always loads the source code, and not the compiled files,
in CMUCL, because the extension, that is, :type is defaulted too, and
I, obviously, don't compile "all". Needless to mention, that I don't
explicitly supply ".lisp", it is an inherited default.

(let ((*default-pathname-defaults* (pathname-directory
*load-pathname*)))

would be a naive way to fix the problem, but CMUCL conveniently returns
NIL as pathname directory for "all", and then load signals an error
becaus *default-pathname-defaults* is NIL, and not #p"".

A solution is (let ((*default-pathname-defaults* (or
(pathname-directory *load-pathname*) (pathname ""))) but in my opinion
it is just the very cause why the AI winter had come.

I didn't try it with sbcl because sbcl's macros implementation doesn't
work well enough to handle my macros, sorry. 

David

From: ············@gmail.com
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <1110281853.658885.53900@o13g2000cwo.googlegroups.com>
> (let ((*default-pathname-defaults* *load-pathname*))
>


let ((*default-pathname-defaults* (make-pathname :type nil :defaults
*load-pathname*)))

seems to do what I want, except that it does not work in LispWorks.
From: Marco Antoniotti
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <xWmXd.46$fp1.64803@typhoon.nyu.edu>
You forgot the :NAME NIL part.

Try that.

Also, try MK:DEFSYSTEM or ASDF.   Much better than handling your own 
"load" script.

Cheers

marco




············@gmail.com wrote:
>>(let ((*default-pathname-defaults* *load-pathname*))
>>
> 
> 
> 
> let ((*default-pathname-defaults* (make-pathname :type nil :defaults
> *load-pathname*)))
> 
> seems to do what I want, except that it does not work in LispWorks.
> 
From: ············@gmail.com
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <1110349951.131802.25580@z14g2000cwz.googlegroups.com>
Marco Antoniotti wrote:
> You forgot the :NAME NIL part.
>
> Try that.
>
> Also, try MK:DEFSYSTEM or ASDF.   Much better than handling your own
> "load" script.
>


Except that I spent time making  MK:DEFSYSTEM (version 3) work with
OpenMCL. It does not handle :unspecific as return value from
pathname-host, and fails due to that. Handling your own small piece of
code is much easier than some other's buggy one.
From: Marco Antoniotti
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <oEEXd.48$fp1.66946@typhoon.nyu.edu>
············@gmail.com wrote:
> Marco Antoniotti wrote:
> 
>>You forgot the :NAME NIL part.
>>
>>Try that.
>>
>>Also, try MK:DEFSYSTEM or ASDF.   Much better than handling your own
>>"load" script.
>>
> 
> 
> 
> Except that I spent time making  MK:DEFSYSTEM (version 3) work with
> OpenMCL. It does not handle :unspecific as return value from
> pathname-host, and fails due to that. Handling your own small piece of
> code is much easier than some other's buggy one.

Submitting a bug report to the maintainers so that maybe they can fix 
the bug (for you and others) is even more intelligent behavior.

Having said that, please show me the changes you made and I will 
incorporate them into MK:DEFSYSTEM.


Cheers
--
Marco
From: Svein Ove Aas
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <d0karv$rrk$1@services.kq.no>
············@gmail.com wrote:

>> (let ((*default-pathname-defaults* *load-pathname*))
>>
> 
> 
> let ((*default-pathname-defaults* (make-pathname :type nil :defaults
> *load-pathname*)))
> 
> seems to do what I want, except that it does not work in LispWorks.

As an aside, have you tried using ASDF?
It seems to fit what you're doing.
From: ············@gmail.com
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <1110293707.419949.260900@o13g2000cwo.googlegroups.com>
Yes, ASDF works, but has other subtle problems; I just want to load all
files from the same directory from which I load the "root" file. I hope
not to need a library for that. It's two lines of lisp, after all.
From: Raymond Toy
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <sxdvf82qk9k.fsf@rtp.ericsson.se>
>>>>> "David" == david ······@gmail com <············@gmail.com> writes:

    David> would be a naive way to fix the problem, but CMUCL
    David> conveniently returns NIL as pathname directory for "all",

This is probably because your initial *d-p-d* is #p"".  If you want
this to work you probably want to set *d-p-d* appropriately.  Then
*load-pathname* will have the full pathname.

I think your final solution of (make-pathname :type nil :defaults
*load-pathname*) is probably the best.

    David> I didn't try it with sbcl because sbcl's macros implementation doesn't
    David> work well enough to handle my macros, sorry. 

There's probably a subtle error in your macros.

Ray
From: ············@gmail.com
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <1110299803.224026.213860@f14g2000cwb.googlegroups.com>
>     David> would be a naive way to fix the problem, but CMUCL
>     David> conveniently returns NIL as pathname directory for "all",
>
> This is probably because your initial *d-p-d* is #p"".  If you want
> this to work you probably want to set *d-p-d* appropriately.  Then
> *load-pathname* will have the full pathname.
>

Of course it is because *d-p-d* is #p"". And the whole question is how
to set up *d-p-d* accordingly so that (load "foo") loads foo from the
directory, compiled if it is.

> I think your final solution of (make-pathname :type nil :defaults
> *load-pathname*) is probably the best.
>
>     David> I didn't try it with sbcl because sbcl's macros
implementation doesn't
>     David> work well enough to handle my macros, sorry.
>
> There's probably a subtle error in your macros.

Probably. Loading  a file with the following content (only):

(setf *default-pathname-defaults*
	(make-pathname :type nil :defaults *load-pathname*))

twice in the top-level loop causes SBCL to say:

* (load "all1")

T
* (load "all1")

debugger invoked on a SB-INT:BUG in thread 17155:
    failed AVER: "(NOT (RELATIVE-UNIX-PATHNAME? PATHNAME))"
  This is probably a bug in SBCL itself. (Alternatively, SBCL might
have been
  corrupted by bad user code, e.g. by an undefined Lisp operation like
  (FMAKUNBOUND 'COMPILE), or by stray pointers from alien code or from
unsafe
  Lisp code; or there might be a bug in the OS or hardware that SBCL is
running
  on.) If it seems to be a bug in SBCL itself, the maintainers would
like to
  know about it. Bug reports are welcome on the SBCL mailing lists,
which you
  can find at <http://sbcl.sourceforge.net/>.

You can type HELP for debugger help, or (SB-EXT:QUIT) to exit from
SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT   ] Reduce debugger level (leaving debugger, returning to
toplevel).
  1: [TOPLEVEL] Restart at toplevel READ/EVAL/PRINT loop.
(SB-INT:BUG 2 ··@<failed AVER: ~2I~_~S~:>")[:EXTERNAL]
0]

SBCL 0.8.19 on PowerPC/Mac OS X 10.3.8.


David
From: Raymond Toy
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <sxdmzteqe2e.fsf@rtp.ericsson.se>
>>>>> "David" == david ······@gmail com <············@gmail.com> writes:

    David> would be a naive way to fix the problem, but CMUCL
    David> conveniently returns NIL as pathname directory for "all",
    >> 
    >> This is probably because your initial *d-p-d* is #p"".  If you want
    >> this to work you probably want to set *d-p-d* appropriately.  Then
    >> *load-pathname* will have the full pathname.
    >> 

    David> Of course it is because *d-p-d* is #p"". And the whole question is how
    David> to set up *d-p-d* accordingly so that (load "foo") loads foo from the
    David> directory, compiled if it is.

In my cmucl init, I just do

    (setf *default-pathname-defaults* (pathname (default-directory)))


    >> I think your final solution of (make-pathname :type nil :defaults
    >> *load-pathname*) is probably the best.
    >> 
    David> I didn't try it with sbcl because sbcl's macros
    David> implementation doesn't
    David> work well enough to handle my macros, sorry.
    >> 
    >> There's probably a subtle error in your macros.

    David> Probably. Loading  a file with the following content (only):

    David> (setf *default-pathname-defaults*
    David> 	(make-pathname :type nil :defaults *load-pathname*))

Maybe you want to say 

    (make-pathname :name nil :type nil :defaults *load-pathname*)

instead?  I'm not that familiar with sbcl's pathnames.

Ray
From: ············@gmail.com
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <1110304055.152184.282770@f14g2000cwb.googlegroups.com>
> Maybe you want to say
>
>     (make-pathname :name nil :type nil :defaults *load-pathname*)
>
> instead?  I'm not that familiar with sbcl's pathnames.
>
> Ray

1) It is not needed since :name is not used by load.

2) it still causes the internal error in SBCL. In general, I am hit by
internal errors in SBCL, as well as by bugs in the macro facility every
now and then. Perhaps, I am just unlucky.

David
From: Raymond Toy
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <sxd6502q99w.fsf@rtp.ericsson.se>
>>>>> "David" == david ······@gmail com <············@gmail.com> writes:

    >> Maybe you want to say
    >> 
    >> (make-pathname :name nil :type nil :defaults *load-pathname*)
    >> 
    >> instead?  I'm not that familiar with sbcl's pathnames.
    >> 
    >> Ray

    David> 1) It is not needed since :name is not used by load.

Oops.  You're right.  Or rather. load already has a name so when it
merges with *d-p-d*, it doesn't use the name component from *d-p-d*.

    David> 2) it still causes the internal error in SBCL. In general, I am hit by
    David> internal errors in SBCL, as well as by bugs in the macro facility every
    David> now and then. Perhaps, I am just unlucky.

I'm not an sbcl user.  Perhaps you should ask them about it.

Ray
From: Marco Antoniotti
Subject: Re: so, which of the lisps works?
Date: 
Message-ID: <zJlXd.45$fp1.65665@typhoon.nyu.edu>
Using MK:DEFSYSTEM for these sort of things usually works better.

············@gmail.com wrote:
> I am trying to make relative paths work. In all.lisp, I have
> 
> (let ((*default-pathname-defaults* *load-pathname*))
> 
> and hope that all files will be relative from the all.lisp's directory
> when I invoke
> 
> (load "all")
> 
> This almost works with most implementations (lisworks, openmcl,clisp).
> However, it always loads the source code, and not the compiled files,
> in CMUCL, because the extension, that is, :type is defaulted too, and
> I, obviously, don't compile "all". Needless to mention, that I don't
> explicitly supply ".lisp", it is an inherited default.
> 
> (let ((*default-pathname-defaults* (pathname-directory
> *load-pathname*)))
> 
> would be a naive way to fix the problem, but CMUCL conveniently returns
> NIL as pathname directory for "all", and then load signals an error
> becaus *default-pathname-defaults* is NIL, and not #p"".
> 
> A solution is (let ((*default-pathname-defaults* (or
> (pathname-directory *load-pathname*) (pathname ""))) but in my opinion
> it is just the very cause why the AI winter had come.

You want to make sure that your rebinding of *default-pathname-defaults* 
does contain a proper pathname.  A suggestion (YMMV) is to do the following

(let ((*default-pathname-defaults*
        (make-pathname :name nil
                       :type nil ; Be careful with this.
                       :defaults *load-pathname*))
       )
    ...
    )

In this way your "new" *default-pathname-defaults* will hold a pathname 
of your liking.

Cheers
--
Marco