3 ms·
I do not know Haskell enough to fully judge this, so maybe someone can correct me, but that seems _very_ minimal. From what I understand, it doesn't even have a
by stiff 15y ago
I do not know Haskell enough to fully judge this, so maybe someone can correct me, but that seems _very_ minimal. From what I understand, it doesn't even have arithmetic operations, it "executes" incorrect programs without any error (try repl "())") and also it doesn't have any kind of scoping, for example in the following code a function argument is bound in the global (and only) environment:
Main> repl "(begin ((fun (x y) y) 1 2) y)"
([("x",Number 1),("y",Number 2),("begin",Fun),("car",Fun),("cdr",Fun),("cons",Fun),("cond",Fun),("def",Fun),("eval",Fun),("fun",Fun),("t",Symbol "t"),("quote",Fun)],Number 2)
I don't think it's fair to call this a Lisp at all at this point. There is a nice writeup of implementing a Lisp in Python by Peter Norvig, where at least the most basic things are implemented correctly (and the code is documented): http://norvig.com/lispy.html http://norvig.com/lispy.html
Also, I get errors even with some very simple statements that theoretically seem to be implemented like:
Main> repl "(cons 1 2)"
([("begin",Fun),("car",Fun),("cdr",Fun),("cons",Fun),("cond",Fun),("def",Fun),("eval",Fun),("fun",Fun),("t",Symbol "t"),("quote",Fun)],List
[Exception: lisp.hs:48:8-48: Irrefutable pattern failed for pattern (ctx', [v', (Main.List vs')])
Am I doing something wrong here?
- sjs 15y agoThis is clearly a golfing exercise. If you want a more full featured Lisp check out Write Yourself A Scheme in 48 Hours by Jonathan Tang: http://jonathan.tang.name/files/scheme_in_48/tutorial/overview.html http://jonathan.tang.name/files/scheme_in_48/tutorial/overvi...
- die_sekte 15y ago(a) The empty list is treated as nil. (b) The scoping is in fact strange; what you saw, however, was a bug. (c) cons expects a list as its second argument. This certainly isn't useable for anything, but I think it comes somewhat close to being lisp.