Artyomska
Artyomska

Reputation: 1335

File loading difficulties in clisp

So I am trying to learn Lisp, and I downloaded GNU CLISP 2.49 on my Windows 10 PC. I wrote some code in a file already, and I want to load it from the CLISP terminal with the (load "example.lisp") command.

Where should I put the file to be able to load it like this in clisp?

I have the clisp installed in C:\clisp-2.49.

Upvotes: 0

Views: 5697

Answers (4)

Cian Moriarty
Cian Moriarty

Reputation: 101

clisp-2.49-win32-mingw-ming-big.exe will not work if the current directory has spaces in it. Make sure that your directory does not have any spaces in it.

Upvotes: 0

Joshua Joost
Joshua Joost

Reputation: 1

If you want to load a file from your Desktop directory you can do:

(load "../../Users/User/Desktop/Dateiname.lisp")

Upvotes: 0

Kaz
Kaz

Reputation: 58500

In addition to sds's excellent answer, here is a Windows perspective.

In a command-line environment on Windows or Unix, you wouldn't run into this issue, because it would be clear that you are are in certain "current working directory":

C:\Users\me\lisp_project> clisp -q
[1]> (load "example.lisp") 

That is, loading a file using a relative path will be relative to this directory. It's clear in the above scenario that if the file C:\Users\me\lisp_project\example.lisp, that is what is loaded (unless someone has reconfigured custom:*load-paths* not to look in the current working directory).

When you start a process using the Windows Explorer GUI, it still has a current working directory. If you start a process by launching an .exe file, its working directory is the directory where that .exe is located.

If you launch an executable through a shortcut, however, the current working directory is determined by a property of the shortcut. You can edit this: right click on the shortcut and change the "Start in" directory to whatever you want.

In other words, you can make a shortcut to clisp.exe, place it into whatever folder you are working in, and have it "start in" that folder.

This approach should work for any language interpreter, including those which lack the sophistication of CLISP's custom:*load-paths*.

Upvotes: 4

sds
sds

Reputation: 60004

You should start with the docs for the load function, and the bottom of the page will give you the answer:

Variable CUSTOM:*LOAD-PATHS*. The variable CUSTOM:*LOAD-PATHS* contains a list of directories where the files are looked for - in addition to the specified or current directory - by LOAD, REQUIRE, COMPILE-FILE and LOAD-LOGICAL-PATHNAME-TRANSLATIONS.

So, you should examine the variable custom:*load-paths* and add your directory there:

(pushnew #p"c:/home/lisp/" custom:*load-paths* :test #'equalp)

or you can run clisp in the directory where your sources are located.

PS. You now owe me 1 zorkmid. :-)

Upvotes: 6

Related Questions