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
Erlang on Twitter
» ITmozg_jobs (ITmozg_jobs): Программист-разработчик Erlang/Java|Ростов-на-Дону|от 30000руб. до 40000руб.|TradingView|http://t.co/7IZwL4uC7P
» 5HT (Namdak Tonpa): We want to create opportunity for PHP/Python/Ruby freelance developer to switch to Erlang. #FuryN2O
» erlnews (Erlang news): Mnesia - Check for a value in either of the keys in the table #erlang http://t.co/Lro8B4DWSz
» antonwhalley (Anton Whalley): @mckenna1977 http://t.co/IjUin825lm you in town?
» yaaliia (Nurlia Febrianti): Wee abng ne:p kteg* adk kurus mcem ne haha”@doni_erlang: Tedok gteros dek pantasla endut :D “@yaaliia: bokbok siang dlu.
» antonwhalley (Anton Whalley): ? http://t.co/IjUin825lm fancy it
» rsslldnphy (Russell Dunphy): @llaisdy @davestrock @erlanginfo ha! In case it’s not clear, I love Erlang, and its syntax. Couldn’t describe it as pretty though.
» ErlAng_fei (Erlina Anggraeni Fei): RT @GJane_: “Karena ketakutanku selama ini, hanyalah memori-memori manis yang kuciptakan bersamamu, perlahan menggerus diriku dan semakin m…
» yukiex (Yuki Komatsu): ejabberd.cfgの%%%はコメントなのか・・・Erlangのルール?
» phuteradhimas (phuteradhimas): @doni_erlang lo tuh gemini sesuka sama jenis haha
Statistics
Number of aggregated posts: 10650
Most recent article: May 20, 2013
Latest comments
» Moraru on This is Why You Spent All that Time Learning to Program: It is true that computer science was a pain in the back at time that i’ve had to learn it…
» Commercial hand dryers on Couchbase Meetup at new HQ: Buy online from here where you will get so much of variety in Commercial hand dryers for people. If you…
» Fort McMurray Homes on Motivated Reasoning and Erlang vs Python vs Node: I don’t really understand why this post is motivational? I don’t even see a post, just a title. Fort McMurray…