34

Python

When I learned Python I installed it on windows with a nice gui installer and all .py files would automatically run in python, from the command line or explorer.

I found this very intuitive and easy, because I could instantly make plain text files and run them.

Lisp

I'm starting to learn lisp and have decided (from reviews) that SBCL is not a bad lisp implementation.

Is there a way to setup SBCL to run .lisp files as easily as with Python?

Are there other lisp implementations that have this?

1
  • 2
    I suggest at least trying the SLIME way of doing things. Interactive development is a major part of what makes Lisp great, after all. Jun 10, 2010 at 21:45

4 Answers 4

27

Executables

SBCL can save executable images, as Greg Harman mentions (see the :EXECUTABLE keyword): http://www.sbcl.org/manual/index.html#Saving-a-Core-Image

Scripts

Lisp files can be executed as scripts, see: http://www.sbcl.org/manual/#Shebang-Scripts

Command Line Options

SBCL has command line options to evaluate/load lisp code on start: http://www.sbcl.org/manual/#Command-Line-Options

SLIME

SLIME is an Emacs interface for Common Lisp. One can use SBCL via SLIME from within Emacs. Many people prefer Emacs Lisp listeners over typical shell interfaces.

Most Common Lisp implementations have similar capabilities. For details consult their manual or ask here for specific implementations.

0
11

A few minutes ago someone replied with an answer nearing what I was looking for.

The reply linked to http://www.sbcl.org/manual/Shebang-Scripts.html which was a great help in figuring out my solution. Whoever it was shouldn't have removed their answer as I was about to mark it as correct ;)

My final solution was to create a batch script that is linked through normal program file association as the program to open .lisp files (Right click file->Properties->Opens With->[Change]).

@ECHO OFF
"C:\Program Files\Steel Bank Common Lisp\1.0.37\sbcl.exe" --script %1

When you double click files in explorer it executes them and when you run them in the command line it does the same.

0
2

SBCL can save an executable core image via sb-ext:save-lisp-and-die

1

If you have already downloaded and installed the SBCL interpreter, then in order to run your programs by simply entering them into the command line you need to add the location of the interpreter to your system PATH variable, so that your machine knows where to look.

This is true for any language. What the Python installer did was add the location of the Python interpreter to your PATH environment variable.

Depending on your platform, do a quick Google search on how to set environment variables.

1
  • I have tried adding the location of "sbcl.exe" to the PATH env variable, however this doesn't seem to change anything. I have also tried setting "sbcl.exe" to be the default program that opens .lisp files in windows explorer. Neither of these allow me to run lisp files directly.
    – AnnanFay
    Jun 7, 2010 at 20:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.