Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Different behavior of SBCL and CLISP on 'directory' function

2 views
Skip to first unread message

Anton Kazennikov

unread,
Nov 21, 2009, 2:19:28 PM11/21/09
to
Hello!

I've got different behavior on sbcl and clisp in the following
situation. I have a simple directory structure:
.
./systems/s-xml
./systems/cl-gd
./systems/cdg

Now, I want to get all files/directories under systems.
In sbcl, i do (directory "systems/*.*") and I get what I want.
In clisp, i do the same, and I get nil. I also tried to construct the
pathname using make-pathname/merge-pathname, but under the clisp the
result is the same - nil.

What result is right? And how to do the thing I want in a portable way?

Stanislaw Halik

unread,
Nov 21, 2009, 2:28:22 PM11/21/09
to
Anton Kazennikov <kazen...@gmail.com> writes:

> Now, I want to get all files/directories under systems.
> In sbcl, i do (directory "systems/*.*") and I get what I want.
> In clisp, i do the same, and I get nil. I also tried to construct the
> pathname using make-pathname/merge-pathname, but under the clisp the
> result is the same - nil.
>
> What result is right? And how to do the thing I want in a portable
> way?

Pathnames are deliberately underspecified in CLHS. CL-FAD offers some
layer of compatibility:

CL-USER> (documentation 'cl-fad:list-directory 'function)
"Returns a fresh list of pathnames corresponding to the truenames of
all files within the directory named by the non-wild pathname
designator DIRNAME. The pathnames of sub-directories are returned in
directory form - see PATHNAME-AS-DIRECTORY."

--
polscy Lispnicy, łączmy się -- #lisp-pl na freenode

Pascal J. Bourguignon

unread,
Nov 21, 2009, 4:03:20 PM11/21/09
to
Anton Kazennikov <kazen...@gmail.com> writes:

> Hello!
>
> I've got different behavior on sbcl and clisp in the following
> situation. I have a simple directory structure:
> .
> ./systems/s-xml
> ./systems/cl-gd
> ./systems/cdg
>
> Now, I want to get all files/directories under systems.
> In sbcl, i do (directory "systems/*.*") and I get what I want.

But 'erroneously'. "systems/*.*" is a file pathname, so you should
get only files (from the point of view of Common Lisp; of course, from
the point of view if unix, directories are files, hence the behavior
of SBCL).


Try: (append (directory "systems/*/") (directory "systems/*.*/"))
if you want both directories with and without dots, or just:

(directory "systems/*/")

if your directories don't contain dots.


> In clisp, i do the same, and I get nil. I also tried to construct the
> pathname using make-pathname/merge-pathname, but under the clisp the
> result is the same - nil.

(make-pathname :directory '(:relative "SYSTEMS" :wild)
:name nil :type nil :version nil :case :common)

--> #P"systems/*/" ; in both clisp and sbcl...


> What result is right? And how to do the thing I want in a portable way?

To do pathname stuff in a portable way is really difficult. Even
perhaps impossible. AFAIK, the only thing you can do portably is to
use logical pathnames to access only a subset of the files in the
physical file system (and not the same subset depending on the
implementation!).

--
__Pascal Bourguignon__

gary.schiltz

unread,
Nov 22, 2009, 5:35:52 PM11/22/09
to

Since no one else has mentioned it, allow me to suggest looking at
chapter 15 of Peter Seibel's excellent (and free, electronically) book
"Practical Common Lisp." The chapter -
http://www.gigamonkeys.com/book/practical-a-portable-pathname-library.html
- is devoted to adding a layer on top of Common Lisp implementations
to abstract away their differences in pathname handling.

;; Gary

Pascal Costanza

unread,
Nov 22, 2009, 5:55:36 PM11/22/09
to

Stanislaw already mentioned CL-FAD, which is actually based on the code
in that book, but is further improved.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/

0 new messages