The function
current-pathname
is useful for loading other files relative to a file.
current-pathname
computes a pathname from the current operation as follows:
Uses
*compile-file-pathname*
.
When evaluating or compiling an Editor buffer
Uses the pathname of the buffer, if available, otherwise uses the current working directory.
Uses the current working directory.
The pathname computed above is then translated to a physical pathname, and the argument
relative-pathname
is merged with this physical pathname. The
pathname-type
of the result
pathname
is set to
type
if supplied, the
pathname-version
is set to
:newest
, and
pathname
is returned.
A useful value for
type
is
nil
, which can be used to allow
load
to choose between lisp or fasl regardless of the type of the current pathname.
Note:
defsystem
uses
current-pathname
with its :
default-host
argument.
Suppose you want the file
foo
to load the file
bar
.
While loading the source file
foo.lisp
:
=>
#P"C:/temp/bar.lisp"
While loading the binary file
foo.fsl
:
=>
#P"C:/temp/bar.fsl"
To load
bar.lisp
or
bar.fsl
according to the value of
*load-fasl-or-lisp-file*
, regardless of whether
foo.lisp
or
foo.fsl
is being loaded, specify
type
nil
:
(load (current-pathname "bar" nil))