Wasp Lisp - a Small Scheme-like Lisp
Chris Double - noreply@blogger.com (Chris Double) - November 27, 2009Wasp Lisp is a small Scheme-like Lisp implementation developed by Scott Dunlop. It features a lightweight concurrency model (with similarities to Erlang and Termite).
Wasp Lisp was originally derived from MOSREF - the Mosquito Secure Remote Execution Framework. It includes an implementation of MOSREF so can do similar things that the original was built for.
Wasp feels a lot like Scheme. It has a REPL which you can use to try Lisp interactively. You can spawn lightweight threads and use channels to communicate between threads. Here’s a simple example with a thread that loops forever, waits for data to be sent to a channel and then prints that out. From the REPL strings are interactively sent to the channel:
$ rlwrap ../wasp
>> (define channel (make-queue))
:: [queue 98154C0]
>> (define (looper channel)
.. (forever
.. (define data (wait channel))
.. (print data)))
:: looper
>> (spawn looper channel)
:: [process looper]
>> (send "hello\n" channel)
hello
:: [queue-output 9815500]
>> (send "world\n" channel)
world
:: [queue-output 9815500]
Threads are co-operative in Wasp. You need to manually yield to switch from a thread. The following example doesn’t manually yield and will constantly print ‘a’ to the terminal:
(begin
(spawn
(lambda ()
(forever (print "a\n"))))
(spawn
(lambda ()
(forever (print "b\n")))))
To yield you use the ‘pause’ function. Adding this to the ‘forever’ loop in the example above will switch between the two threads:
(begin
(spawn
(lambda ()
(forever
(pause)
(print "a\n"))))
(spawn
(lambda ()
(forever
(pause)
(print "b\n")))))
Wasp Lisp code can get compiled to a compact bytecode format using the ‘waspc’ command. This can produce a binary executable for the platform:
$ cat >test.ms
(define (main)
(print "hello world!\n"))
$ waspc -exe hello test.ms
BUILD: test
BUILD: core/macro
BUILD: core/config
BUILD: site/config
BUILD: core/file
BUILD: core/module
BUILD: core/io
BUILD: core/macro
BUILD: core/config
BUILD: site/config
BUILD: core/file
BUILD: core/module
BUILD: core/io
BUILD: test
$ chmod +x hello
$ ./hello
hello world!
There is quite a bit of example code, including a simple HTTP server:
$ rlwrap ../wasp
>> (import "lib/http-file-server")
:: #t
>> (offer-http-file 2080 "/test" "text/plain" "Hello world!")
:: [queue 985A1F0]
This serves the text ‘Hello world!’ when http://localhost:2080/test is requested. The Wasp VM site has an informal speed test of serving data comparing against THTTPD.
Wasp builds and runs on Linux, Mac OS X and Windows. Instructions for building and links to other information are here. The source is available on launchpad. libevent is needed to build.
Categories: waspvmCategories: Blogs Chris Double
Comments
No comments so far, you could be the first.Add comment
Erlang on Twitter
» MQuotient (MQuotient Solutions): Great start to seminars at MQ. Started with Fundamentals of statistics, Concurrency with Erlang, Python tricks and Advanced Git
» a2zmax (這いよれ!あずまっくす): RT @matsumotory: erlang入れるのに、久々にepel使ってる
» matsumotory (MATSUMOTO, Ryosuke): erlang入れるのに、久々にepel使ってる
» csanz (Christian Sanz): earlang community is kinda weak ATM http://t.co/pJCU5TSY
» dooridho (Ridho Septiansyah): Hha kirimlah boy nak jadiin DP :D “@doni_erlang: Mantap” boy,haha RT @dooridho: @doni_erlang boy poto kemaren gimano :D”
» doni_erlang (Dony Erlangga): Mantap” boy,haha RT @dooridho: @doni_erlang boy poto kemaren gimano :D
» dooridho (Ridho Septiansyah): @doni_erlang boy poto kemaren gimano :D
» 9renpoto (Keisuke Kan): EndingがErlangに見えるぐらいに視力落ちてる
» doni_erlang (Dony Erlangga): Otak lo yg lemot bro haha RT @rudyprasetio: Lemot amatt ni…
» dtoader (Dragos Toader): Building Erlang OTP R15B from source in cygwin http://t.co/JhSzPZLY
Statistics
Number of aggregated posts: 10504
Number of comments: 2145
Most recent article: May 21, 2012
Latest comments
» sunshine on We Who Value Simplicity Have Built Incomprehensible Machines: How to Get Free Credit Scores Having good credit is imperative in today’s world. There are so many things you…
» cheap stickers printings on A Forgotten Principle of Compiler Design: I really like your way of expressing the opinions and sharing the information. It is good to move as chance…
» jamesmathew on This is Why You Spent All that Time Learning to Program: This could be a good achievement for the small area to have a personal news channel and could really help…