3

Does the LISP program need to be in the same folder as the LISP compiler or can I call it from anywhere?

8
  • 1
    This highly depends on how the program is structured (is it an ASDF system? just a bare function? a single .lisp?) and what lisp compiler you're using. Commented Apr 18, 2011 at 19:20
  • 1
    My favorite way - Seriously - is to run it within emacs. Commented Apr 18, 2011 at 19:21
  • It is a basic .lisp file. And I'm not really sure what compiler would be best to use. I have Windows 7 and most of the LISP compilers I have found don't run on Windows. Commented Apr 18, 2011 at 19:21
  • What is emacs? I have never heard of it. Commented Apr 18, 2011 at 19:32
  • Emacs is a powerful text editor and the favourite IDE of many Lisp programmers (especially combined with SLIME, the Superior Lisp Interaction Mode for Emacs). Emacs uses its own Lisp dialect (Emacs Lisp) as extension language, and most of Emacs itself is actually written in Lisp (there's only a small C core providing the Lisp interpreter and some basic functionality). You can run a Lisp file opened in Emacs directly in it, and don't need to worry about its location on disk. Commented Apr 18, 2011 at 20:40

1 Answer 1

6

The basic operation is to call load with a pathname.

(load #p"/home/user710086/foo.lisp")

Then, you may need to run whatever "main" function is supplied by that file.

The location can also be in the current directory, which is, of course, platform dependent. The current directory usually has nothing to do with the directory the Lisp executable resided in, but is the directory of the shell you called it from. I do not know what the current directory is in Windows when you click on something, but I would guess that it is some home-directory-surrogate.

There are several things that may wrap around that basic operation. Usually, code is organized into an ASDF system, and has defined one or more packages. You would then add the .asd file to asdf:*asdf-registry* and then load the package with

(asdf:load-sys 'foo)

This would load all files defined in the .asd file in a calculated order, thus providing you with the system's functionality.

Sign up to request clarification or add additional context in comments.

2 Comments

What if I have multiple functions inside of the program? Does it matter which one I run first?
It does not matter which you compile first (although it may give warnings if an unknown function name is encountered). You run just the entry point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.