Different behavior of SBCL and CLISP on 'directory' function

Discussion of Common Lisp
Post Reply
kzn

Different behavior of SBCL and CLISP on 'directory' function

Post by kzn » Sat Nov 21, 2009 5:26 am

Hello!

I have following directory structure:
.
./systems/s-xml
./systems/uffi
./systems/cdg

I want to get all entries under systems directory - a list of 3 items.
I call '(directory "systems/*.*")' from . to get the entries.

However, I get different results under sbcl and clisp:
under sbcl the function call works fine and return desired entries,
and under clisp the function call returns nil.
I tried to use make-pathname/merge-pathname, but they yield same results.

Which behavior is right? And if it is implementation dependent, what is the right way to do this?

Harleqin
Posts: 71
Joined: Wed Dec 17, 2008 5:18 am
Location: Bonn, Germany

Re: Different behavior of SBCL and CLISP on 'directory' function

Post by Harleqin » Sun Nov 29, 2009 6:03 am

I guess that your problem is the "*.*". While a special significance is often assigned to the last dot in a filename (the part after it being treated as an "extension"), for naming purposes this is irrelevant---EXCEPT in some operating systems like DOS (and Windows, which is based on it): here, the dot doesn't really "exist" but is just a notation for showing the two parts of a filename as a single string.

As a consequence, users of DOS and its descendants have a habit or need of writing "*.*", not just "*", when they mean "all files". On other systems, this would mean "all files that have a dot somewhere in their names". Since the directories you showed do not contain dots, this can be a problem of different expectations from the file system and the Lisp system resp. your application.

As an aside, the Common Lisp standard itself makes no assumptions about the underlying operating system; read about its filename handling in the CLHS.

So, the easiest way in your case might be to use "*" instead of "*.*". If you need different designators in different environments, you might have to use conditional reading using the "#+" or "#-" reader macros (see the CLHS).
"Just throw more hardware at it" is the root of all evil.
Svante

Post Reply