On Sat, Apr 25, 2026 at 08:42:18AM +0800, Qian Yun wrote:
> On 4/25/26 8:21 AM, Waldek Hebisch wrote:
> > On Sat, Apr 25, 2026 at 08:01:27AM +0800, Qian Yun wrote:
> >> On 4/25/26 7:53 AM, Waldek Hebisch wrote:
> >>>
> >>> But _why_ do you want this change?
> >>>
> >>
> >> 1. Logically there's no need.
> >>
> >> 2. Currently, on sbcl on windows, we may set *d-p-d* to
> >> something like "somepath/..", which is not canonical,
> >> because we are using probe-file not truename.
> >
> > Hmm, from Lisp HyperSpec:
> >
> > : probe-file returns false if there is no file named pathspec, and
> > : otherwise returns the truename of pathspec.
> >
> > So it looks like sbcl bug.
> >
>
> You said you would like to move away from Lisp specific pathname
> handling, and use string as representation for pathname.
>
> We just removed "merge-pathname", which depends on *d-p-d*.
Let me explain it a bit more. We need to use Lisp calls,
like OPEN, LOAD, COMPILE-FILE, WITH-OPEN-FILE. Maybe this is
full list, maybe not. I would like them to behave as normal
OS functions: given a string representing relative name, they
should handle corresponding file relative to current directory.
Look at COMPILE-FILE for example (this one is nasty). From
HyperSpec:
: input-file---a pathname designator. (Default fillers for
: unspecified components are taken from *default-pathname-defaults*.)
So, to get desired behaviour for relative names *default-pathname-defaults*
must point to current directory, and AFAICS this is enough.
IIRC output file is worse. In HyperSpec I just see "implementation
defined", but IIRC older spec said that full output pathname is
result of 'merge-pathname' applied to input and output arguments of
COMPILE-FILE. In simple cases it worked naturally, but for more
complicated names the result was unexpected (except maybe for people
who know Lisp spec very well). 'relative-to-absolute' was
created to solve this problem: by converting to absolute name
we defeated 'merge-pathname' done by Lisp implementation.
In principle we could try to use 'relative-to-absolute' to
defeat 'merge-pathname' in other places, but to me it looks
simpler and more efficient just make sure that
*default-pathname-defaults* always points to current directory.
> In my previous mail in this thread, we can remove some "turename"
> calls as well, which on some lisps it depends on *d-p-d*.
>
> I would like to remove *d-p-d* for sbcl in |get_current_directory|.
Sure. In a sense most calls to 'truename' are suspect, that is
just using given string as a name should work. Valid uses are
when we need absolute name and possibly if we want to check if
the name is on some list of names. But old code did twisty
things and used 'truename' quite a lot.
> In asdf-uiop, for sbcl, changing directory does not touch *d-p-d*.
> That doesn't breaks thousands of quicklisp packages.
>
> Even if it breaks something in fricas, we will fix it, then
> we are one step further away from lisp specific pathname logic.
As I wrote, we set *default-pathname-defaults* to neutralize
Lisp specific pathname handling.
> The alternative approach for this bug is to set *d-p-d* to
> (sb-unix:posix-getcwd).
>
> I prefer to remove *d-p-d*. What do you think?
You may want to test, but AFAIR without any corrective action
after changing current directory is sbcl, calling Lisp functions
taking filenames as arguments did not work correctly for relative
names. Setting *default-pathname-defaults* fixed this. Since
this behaviour was mandated by HyperSpec, it is unlikely to
change between sbcl versions.
--
Waldek Hebisch