Wednesday, May 12, 2004

Clisp directory handling

The main problem with Lisp implementations, is the open-endedness that they have left for certain portions of the implementation. A very good example is the "directory" function which works differently on different flavours of CL. This is despite the fact that it has been listed in the CLHS. Some of the variance also probably comes from the different operating systems, which have their own representations. I mainly use Clisp for portability across OS's. The other ones like CMU CL, SBCL, OpenMCL, Corman Lisp etc are ahead in some respects and offer native code compilation but are way behind on portability.

On Clisp just typing


will list all files in the current directory

(directory "*.txt")

will list all files with a .txt extension in the current directory

(directory "/usr/local/apache2/cgi-bin/*.lisp")

can be used for a specific directory.

(directory "*")

fortunately works with most flavours.

(directory "*/")

Will list only sub-directories. This can be useful for some system programs. To get a listing of everything in a directory including sub-directories in Clisp

(append (directory) (directory "*/"))

nconc can also be used instead of append.

There is a lot more information available here. I was very happy to read that Clisp does have these despite the fact that many people criticize it for some things.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home