Tiny Lisp interpreter added

41 views
Skip to first unread message

The Beez

unread,
Apr 24, 2015, 12:49:40 PM4/24/15
to 4th-co...@googlegroups.com
Hi 4tH-ers!

Someone had asked me to add a Lisp interpreter to 4tH. Well, there is a slight problem with that: I don't know the language too well. However, I came across a tiny implementation that was so vanilla that I had to try it. And it worked. I simply yanked a whole bunch of Forth compatibility layers in (didn't even convert the file I/O), added the locals library and off we go.

Sure, I encountered some bumps, but not too many, so it was running within minutes. I think I'm missing out stuff but I really rely on you guys to add it. Note it does a whole bunch of allocations and never frees anything so at some point in time you may run out of memory. Well, at least you can now write stuff like:

(define twice
  (lambda (x)
    (+ x x)))

(display (twice (twice 1)))


Or:

(define fac
  (lambda (n)
    (cond ((eq? n 1)
          1)
          (t
          (* n (fac (- n 1)))))))

(display (fac 5))


As far as I understand, you could even turn it into a library and sent strings to be interpreted to this implementation. Source in SVN.

Hans Bezemer

Ron K. Jeffries

unread,
Apr 24, 2015, 2:23:55 PM4/24/15
to 4th-co...@googlegroups.com
Damn, you are good. And quick.

---
Ron K. Jeffries





--
You received this message because you are subscribed to the Google Groups "4tH-compiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 4th-compiler...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

timi...@gmail.com

unread,
Apr 25, 2015, 2:12:18 AM4/25/15
to 4th-co...@googlegroups.com
so great

The Beez <the.bee...@gmail.com>编写:

Reply all
Reply to author
Forward
0 new messages