Interpreter framework for Lisp-based extension and scripting languages on macOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
LispKit is a framework for building Lisp-based extension and scripting languages for macOS applications. LispKit is fully written in the programming language Swift. LispKit implements a core language based on the R7RS (small) Scheme standard. It is extensible, allowing the inclusion of new native libraries written in Swift, of new libraries written in Scheme, as well as custom modifications of the core environment consisting of a compiler, a virtual machine as well as the core libraries.
So far, performance was not a priority in the development of LispKit. The LispKit compiler does not perform many code optimizations and the performance of the system is below state of the art Lisp and Scheme implementations.
The NumericalScheme demo showcases how to create a derived LispKit interpreter that inherits everything from LispKit (without code duplication) and defines a new native as well as Scheme-based library.
LispPad implements a simple, lightweight, integrated development environment for LispKit on macOS with a Cocoa-based UI. The LispPad Library Reference documents the core LispPad and LispKit libraries in PDF form. A simpler command-line tool with similar functionality is provided by the LispKit framework itself (see below).
LispKit provides support for the following core features, many of which are based on R7RS:
(lispkit system os),
(lispkit draw turtle),
(lispkit sxml xml),
(lispkit sxml html), and
LispKit is incompatible or incomplete with respect to the following R7RS features:
syntax-rulesare not matched based on their definition but their symbol identity
#;do not always work as in other Scheme dialects.
The following SRFI libraries have been ported to LispKit and are included in the framework:
=>in case clauses
The project defines three different targets:
From an architectural perspective, LispKit consists of:
Details can be found in the LispKit Wiki.
This project also includes a command-line tool, called the LispKit Shell, for executing LispKit applications in the terminal. It can be used to try out and experiment with the LispKit framework. The command-line tool can also be used interactively as a read-eval-print loop. The read-eval-print loop parses the entered LispKit expression, compiles it to bytecode, executes it, and displays the result.
First, clone the LispKit repository via
git. The following command will create a directory
> git clone https://github.com/objecthub/swift-lispkit.git Cloning into 'swift-lispkit'... remote: Enumerating objects: 14, done. remote: Counting objects: 100% (14/14), done. remote: Compressing objects: 100% (12/12), done. remote: Total 5300 (delta 1), reused 14 (delta 1), pack-reused 5286 Receiving objects: 100% (5300/5300), 1.76 MiB | 132.00 KiB/s, done. Resolving deltas: 100% (3724/3724), done.
Next, switch to Xcode and build the LispKit command-line tool via scheme
> open LispKit.xcodeproj
A debug binary can be built in the following way:
> cd swift-lispkit > swift build -Xswiftc "-D" -Xswiftc "SPM" Fetching https://github.com/objecthub/swift-numberkit.git Fetching https://github.com/objecthub/swift-commandlinekit.git Fetching https://github.com/objecthub/swift-markdownkit.git Completed resolution in 6.47s Cloning https://github.com/objecthub/swift-numberkit.git Resolving https://github.com/objecthub/swift-numberkit.git at 2.3.2 Cloning https://github.com/objecthub/swift-markdownkit.git Resolving https://github.com/objecthub/swift-markdownkit.git at 0.2.0 Cloning https://github.com/objecthub/swift-commandlinekit.git Resolving https://github.com/objecthub/swift-commandlinekit.git at 0.3.1 [124/124] Linking LispKitRepl
The debug binary can be run by invoking
.build/debug/LispKitRepl -d LispKitassuming that directory
~/Documents/LispKitcontains a copy of the resources directory needed to run the command-line tool.
A release binary can be built like this:
> cd swift-lispkit > swift build -c release -Xswiftc "-D" -Xswiftc "SPM" Fetching https://github.com/objecthub/swift-numberkit.git Fetching https://github.com/objecthub/swift-commandlinekit.git Fetching https://github.com/objecthub/swift-markdownkit.git Completed resolution in 4.02s Cloning https://github.com/objecthub/swift-numberkit.git Resolving https://github.com/objecthub/swift-numberkit.git at 2.3.2 Cloning https://github.com/objecthub/swift-markdownkit.git Resolving https://github.com/objecthub/swift-markdownkit.git at 0.2.0 Cloning https://github.com/objecthub/swift-commandlinekit.git Resolving https://github.com/objecthub/swift-commandlinekit.git at 0.3.1 [6/6] Linking LispKitRepl
The release binary can be run by invoking
.build/release/LispKitRepl -r Sources/LispKit/Resourcesin the directory
swift-lispkit(in which the binary was build above).
Assuming that directory
~/Documents/LispKitcontains a copy of the resources directory, it is also possible to run the release binary by invoking
.build/release/LispKitRepl -d LispKit.
The following technologies are needed to build the components of the LispKit framework. For building the command-line tool, all that is needed is the Swift Package Manager. For compiling the framework and trying the command-line tool directly in Xcode, the Swift Package Manager is not needed.