Skip to content

This Xcode project showcases how to extend Swift LispKit. The project implements a read-eval-print loop for an extended LispKit language supporting native flonum vectors and arrays.

License

Notifications You must be signed in to change notification settings

objecthub/swift-numericalscheme

Repository files navigation

Swift NumericalScheme

Platform: macOS Language: Swift 5.7 IDE: Xcode 14 Carthage: compatible License: Apache 2.0

This Xcode project showcases how to extend Swift LispKit. The project implements a read-eval-print loop for an extended LispKit language supporting native flonum vectors and arrays. The flonum vectors are implemented in terms of a new native LispKit library (numerical vector), the flonum array library is implemented as a regular Scheme library (numerical array) and uses the flonum vector library in its implementation.

Building the tool

Xcode

git clone https://github.com/objecthub/swift-numericalscheme
cd swift-numericalscheme
carthage bootstrap --platform macOS
open NumericalScheme.xcodeproj

The NumericalScheme command-line tool is built via the scheme NumericalScheme of the Xcode project and can be executed directly in Xcode. For running the tool in a terminal, using the Swift Package Manager is the preferred approach.

Swift Package Manager

git clone https://github.com/objecthub/swift-numericalscheme
cd swift-numericalscheme
swift build -c release

This will statically link all libraries into one binary .build/release/NumericalScheme. For executing the binary, the tool needs access to the supplemental files coming with LispKit as well as with NumericalScheme itself. These are typically provided via the -r (i.e. --roots) command-line argument. The order of the directory paths matter; i.e. the second path is searched before the first path, so by specifying the NumericalScheme path first, it will be possible to override definitions/libraries provided by the LispKit framework.

This is how the NumericalScheme command-line tool can be invoked (assuming the current directory is the root directoy swift-numericalscheme):

.build/release/NumericalScheme -x -r .build/checkouts/swift-lispkit/Sources/LispKit/Resources Sources/NumericalScheme/Resources

Testing the tool

After starting up the tool, enter the following command in the read-eval-print loop:

(load "Examples/Matrix")

This will load and execute the test program Matrix.scm. If executing the command will results in the output below, everything is set up correctly:

#f64array:(#<f64vector: 1.0 6.0 11.0 2.0 7.0 12.0 3.0 8.0 13.0 4.0 9.0 14.0 5.0 10.0 15.0> 3 5)

Requirements

The following technologies and components are needed to build the NumericalScheme command-line tool:

About

This Xcode project showcases how to extend Swift LispKit. The project implements a read-eval-print loop for an extended LispKit language supporting native flonum vectors and arrays.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published