EmuLisp is a PicoLisp emulator, written in JavaScript. However, in this early version it only covers a tiny subset of PicoLisp. My main motivation for writing this emulator, was that I wanted to learn the PicoLisp basics better.

EmuLisp can be operated through two different front ends: the new EmuLisp Console or the Old Tool. The Console is intended to work somewhat like a normal REPL console, with a few extra features. The Old Tool shows how I started this project. Before I wrote the parser, I entered the Lisp code in a JSON format. The Old Tool also shows you a list of the currently implemented PicoLisp functions.

Both the Console and the Old Tool let you load/run local Lisp (and JavaScript) files, but they do it in different ways. In the Old Tool you'll see a field and a button "Run Lisp file". In the Console you can drag and drop the file(s) onto the console section on the left, if you are lucky to use the right kind of browser. At the moment, Firefox may be the only browser where this works. In both front ends you may also load files using the load function: (load "path/file.l")
The current version of Chrome does not allow loading files from your disk in this way, unless you start Chrome from the command line with the -allow-file-access-from-files parameter. Type about:version on the URL line in Chrome for a hint on how to do that.

For reference documentation on the implemented PicoLisp functions, you should use the original PicoLisp documentation.

Some Console features

The lines that are showing up in the upper part have different background colors depending on their "source" or function. Expressions entered in the lower part are echoed with a light gray background. Data printed using functions like prin and prinl get a light blue background. If the last character printed was a newline, this is indicated by a blue border-bottom. Evaluation results get a light green background and a green border-bottom. Warnings appear with a yellow background, and errors with a red background, both with a thick border-left. If you drag and drop a file onto the console, the file name will show with light gray background and a thick border-left.

Immediately after an expression in the expression field has been evaluated, the content of the field labelled "Expression to monitor" will also be evaluated and the result shown as a tree graph. This requires canvas support. You may at any time refresh the tree graph by clicking on the canvas. You may also use this canvas for doing other kind of graphics. A not yet completed library of canvas functions is provided. If you run EmuLisp off your local disk (and you use a browser that allows access to local files), you can try this in the Console: (load "lib/cv.js" "misc/drawLogo.l")

A mechanism that will give you a warning when you try to leave or close the Console is implemented. Use the Prefs dialog to enable it.

The Console does not work very well with Internet Explorer, except IE9 which looks promising.

Some implementation details

The Number data type is simply the JavaScript Number, which includes floating point numbers. The / function thus does floating point division. However, a /t function is provided in case you need the division(s) to be truncated. The constants π and e are available as js:PI and js:E.

When you define your own functions, you may currently only use these patterns:
(de foo (X Y ...) <prog>), i.e. all arguments evaluated
(de foo @ <prog>), i.e. a variable number of evaluated arguments
(de foo X <prog>), i.e. a variable number of unevaluated arguments

Circular lists may be entered using the (a b c .) notation, and they may also be printed that way. It is, however, not difficult to include such circular lists into other structures so that the simple "circular detector" fails to detect. You may know the result. As long as you stick to "safe circular lists", they shall cause no problem as argument in the length function, or in the expression monitor.

Have fun!

Jon Kleiser, 02-Feb-2011

-  λ  -