A Lisp

Lampas is my first Lisp; currently its unique features include continuations, macros, and some syntactic sugar.

Flagship Features

Macros allow for methods to be specified that will manipulate any S-Expressions which they begin. That is, if a were a macro, any S-Expression led with a would be passed to the macro definition prior to evaluation; an example is below.

Continuations were defined purely with macros. The general workflow of a continuation is to initiate a continuation statement with begincc, and then in the context of the statement, where the value of interest is present, to call call/cc with a lambda taking a continuation as a parameter. That continuation can then be set to a variable for later calling, and an initial value should be returned. Upon calling the continuation, values should be quoted (for now).

[1 2 3]
"=> (1 2 3)"

({|x| (+ 1 x)} 5)
"=> 6"

(defmacro 
  (let name val body) 
  `((lambda (,name) ,body) ,val))
(let a 5 (cons a 2))
"=> (5 2)"

(define print 5)    
((lambda 
  (x) 
  (begincc 
    (write 
      (call/cc {|cc| (set! print cc) x}))))
5)
(print '(+ x 1))
"=> 5
 => 6"

Compilation

Compile the source using GHC and the Existential flag.

$ ghc Main.hs -XExistentialQuantification

Or, if on a Unix machine, run the build script which will compile, test, and clean-up. Support for Windows will be added soon.

$ ./build.sh

Build Script

For the build script to generate documentation, it requires node.js and docco. However, if this aspect is removed it merely requires GHC.

The build script generates documentation, compiles all sources, removes intermediary compilation files, and then runs the test suite. All test results are of the following form in the terminal.

"# Output (= `Hello`)"
"Hello"

Where the asserted value is named with appropriate value in parenthesis. Tests serve to prevent unknown breaking of features.

Usage

Then run the interpreter either with a program as a parameter or individually to fire up a REPL.

$ ./lampas
Lampas >>
$ ./lampas test.lampas

Include the library functions with the following.

(load "Prelude.lampas")