Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simply "run" lisp files

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?

like image 241
AnnanFay Avatar asked Jun 07 '10 20:06

AnnanFay


People also ask

How do I run a Lisp file?

Example: Step 1: After logging into a CUIT machine, enter "lisp" after the $ shell prompt and then hit <return>. Another way is to run lisp via emacs: Meta-x run-lisp (i.e. hit 'esc' followed by 'x', type "run-lisp" and you'll be in lisp mode from which you can load files of lisp code...)

How do I run a Lisp file in Ubuntu?

With CLISP under a unix (like Ubuntu) you can simply add a shebang to the top of your file #!/path/to/clisp and in Ubuntu that would be #!/usr/bin/clisp and it will execute the code as a script. You need the file to contain proper Common Lisp file like: #!/usr/bin/clisp (princ "Hello, world!")

How do I run Sbcl?

To run SBCL, type "sbcl". After startup messages a prompt ("*") appears. Enter a Lisp expression, and SBCL will read and execute it, print any values returned, give you another prompt, and wait for your next input. Most people like to run SBCL as a subprocess under Emacs.

How do I open a Lisp file in Windows?

If you cannot open your LISP file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a LISP file directly in the browser: Just drag the file onto this browser window and drop it.


2 Answers

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.

like image 81
Rainer Joswig Avatar answered Oct 04 '22 21:10

Rainer Joswig


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.

like image 25
AnnanFay Avatar answered Oct 04 '22 20:10

AnnanFay