News for hackers. Stuff that matters.
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by tel on Sunday November 03, 2013 @04:48PM (#6665259)

    > wisp lives in the ST (optionally IO) monad. separate 
    > interpreters with completely segregated environments can be 
    > run concurrently. wisp has a few IO facilities, but they're 
    > completely sandboxed and can't accidentally affect the host 
    > program or environment.
This is wonderful. There's already an embedded R5RS Scheme for Haskell (http://hackage.haskell.org/package/husk-scheme) but it runs everything in the IO monad. That makes it fairly annoying for sandboxed embeddings.
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by JoshTriplett on Monday November 04, 2013 @12:56AM (#6667092)
Apart from its use of ST rather than IO, I'm curious how else Wisp compares to Husk. As far as I can tell, despite the name, Wisp appears to be a Lisp-1 (single namespace for functions and variables, no need to call "apply" or similar on variables referencing functions to call them).
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by dangoor on Sunday November 03, 2013 @04:46PM (#6665243)
Not to be confused with Wisp: Homoiconic JS with clojure syntax, s-expressions and macros: https://github.com/Gozala/wisp
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by espringe on Sunday November 03, 2013 @05:43PM (#6665478)
Or my: https://github.com/espringe/wisp (Whitespace lISP) with f-expressions!
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by akkartik on Sunday November 03, 2013 @08:40PM (#6666192)
You might like my whitespace lisp with f-expressions: http://akkartik.name/blog/wart
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by Myrmornis on Monday November 04, 2013 @05:21AM (#6667820)
Incidentally, why is the scala version 100x slower than the Haskell one?
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by cowward on Sunday November 03, 2013 @06:52PM (#6665716)
Does anyone have any good, language agnostic resources for writing interpreters (not just for lisp)?
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by majika on Sunday November 03, 2013 @09:16PM (#6666343)
/r/compilers [1] has some good resources. You can also check its top submissions [2].

I also recently found Matt Might's Compilers class [3] via a submission here on HN. It has a lot of language-agnostic resources.

[1]: http://www.reddit.com/r/compilers

[2]: http://www.reddit.com/r/compilers/top/

[3]: http://matt.might.net/teaching/compilers/spring-2013/

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by wirrbel on Monday November 04, 2013 @03:23AM (#6667526)
For a quick introduction this might be worth a look (not really language agnostic though) http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by freyrs3 on Sunday November 03, 2013 @09:13PM (#6666337)
Functional or imperative language?
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by ananas on Monday November 04, 2013 @05:02AM (#6667774)
https://github.com/apsk/hlisp Another lisp in haskell
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by sillysaurus2 on Sunday November 03, 2013 @04:39PM (#6665214)
I pine for a Lisp with the embeddable ease of Lua.
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by pygy_ on Sunday November 03, 2013 @05:05PM (#6665336)
It could be trivially implemented in Lua as a pre-processor. Lua has lambdas, higher level functions, lexical scope and tail call elimination.

The main problem is that it doesn't have a ternary operator, making conditional expression problematic to represent (you have to wrap an if statement in a lambda called on the fly).

For something more fully featured, see [0], it is written in MoonScript (which itself compiles to Lua), and the parser depends on LPeg, but writing a S-expression parser is rather easy.

Edit: There's also lcl [1], which is implemented in C. Written by lhf, one of the Lua authors. From the test files, it looks very basic.

--

[0] https://github.com/leafo/moonlisp/tree/master/lisp

[1] http://www.drdobbs.com/open-source/lua-an-extensible-embedde...

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by _mpu on Sunday November 03, 2013 @06:15PM (#6665593)
Wrapping an if in a lambda is unlikely to work as expected.
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by pygy_ on Sunday November 03, 2013 @06:35PM (#6665647)

    ((if foo + -) 4 6)
Can be compiled to

    (function()
        if foo then return plus
        else return minus
        end
    end)()(4, 6)
It is far too verbose to be used in manually crafted Lua, but acceptable if you treat it as a compiler target (with the caveat that the lambda creation will prevent LuaJIT from JITting that piece of code).
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by meric on Monday November 04, 2013 @05:47AM (#6667894)
Plug https://github.com/meric/l2l

"A object-oriented, unicode-enabled lisp that compiles to and runs as fast as Lua. Equipped with macros and compile-time compiler manipulation. Comes with all built-in Lua functions."

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by pygy_ on Monday November 04, 2013 @05:54PM (#6671786)
Nice one! I started coding one after writing the above comment.

I have a question regarding your implementation: why do you use `goto`s rather than `elseif` to compile `(cond)` blocks? For nested blocks?

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by meric on Sunday November 10, 2013 @01:21AM (#6705526)
Oh I think it it was for the return value of cond.
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by chalst on Monday November 04, 2013 @02:21AM (#6667348)
Alex Shinn's Chibi scheme, weighing in at 50kB (but with a dependency on the Boehm garbage collector, which weighs >1 Mb ...), might fit the bill.

Some links

1. Andy Wingo (main Guile implemetor)'s "buyer's guide" to Scheme implementations - http://wingolog.org/archives/2013/01/07/an-opinionated-guide...

2. Chibi Scheme homepage - http://synthcode.com/scheme/chibi/

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by yoklov on Sunday November 03, 2013 @05:24PM (#6665399)
ChibiScheme (https://code.google.com/p/chibi-scheme/) tries to be that. I've considered using it but have avoided it due to its relative newness and a few portability issues.
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by gregburd on Sunday November 03, 2013 @05:48PM (#6665494)
Lysp (http://piumarta.com/software/lysp/) is fairly close to what I'm guessing you're "pining" for and if not, hey it's open source so have at it!
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by yoklov on Sunday November 03, 2013 @06:32PM (#6665636)
Lysp uses a lot of non-standard (and rarely implemented) extensions, and so would be very hard to use in most places.

The author's own Maru (http://piumarta.com/software/maru/) might be better suited for this, but I'm not sure..

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by outworlder on Monday November 04, 2013 @01:52PM (#6670368)
There's also Chicken Scheme.

While maybe not as tiny as Lua, it is designed to be embeddable out of the box.

The FFI is very simple.

Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by wcummings on Sunday November 03, 2013 @04:44PM (#6665238)
Re:Wisp: Small-but-featureful embeddable Lisp interpreter wr... by yoklov on Sunday November 03, 2013 @05:22PM (#6665392)
Unfortunately, Guile is both larger, and less portable than Lua. It's also licensed under the LGPL, which is harder (or impossible) to use in some environments than Lua's MIT-like license.