callisp 0.2.0

A lisp interpreter that can be used with WASM.
Documentation

Callum's Lisp

Build Crates.io Docs Lines of code Files License

A Lisp interpreter designed to be run in the browser using WASM.

Usage

You can perform simple numerical operations using +, -, *, and /:

(+ 1 2) => 3
(/ 5 2) => 2.5
(- 2) => -2
(/ 5) => 0.2

You can define constants using def:

(def x 3) => 3
x => 3

You can create functions using lambda:

(lambda (x) (+ x 1)) => <function>
(def add1 (lambda (x) (+ x 1))) => <unspecified>
(add1 3) => 4

List of all builtin functions and special forms

Special forms

  • def: creates a constant in the current environment
  • lambda or λ: creates a function

Builtin functions

  • +,-,*,/: simple arithmetic operators
  • exit: exits with code 0 or code provided by argument
  • eval: evaluate the expression passed as an argument
  • use: evaluate all expressions contained in a file in the current environment
  • putstr: print a string to stdout
  • readline: read a line from stdin
  • equal?: check if any amount of values are equal
  • >, >=, <, <=: number comparison operators

Goals

  • IO (print, readline, etc.)
  • Macros
  • Tail call elimination
  • Multi-precision numbers
  • Strings
  • Vectors
  • Structs/enums/union types