top | item 44925853

A Lisp in 99LOC

108 points| shikaan | 6 months ago |github.com

26 comments

order

eqvinox|6 months ago

Holy cow this is —structurally, not just expression— some of the worst C code I have ever seen, with the abuse of the 'double' type, 'T' cast that looks like a declaration, endian dependency, and strict aliasing violations galore… does this even work on a modern compiler? o.O

f1shy|6 months ago

Certainly not the worst I have seen, by far; but yes, not pretty. IMHO “Just for making it shorter“. I would very much prefer 200 lines of actually readable nice code.

OhMeadhbh|6 months ago

Yeah. It's munged to fit in 99 lines.

messe|6 months ago

Surpringly readable though, despite all that, if you've ever implanted a language in similar constraints.

forgotpwd16|6 months ago

>C code in this project is strongly Lisp-like in compact form

Kinda reminds me J-flavored Whitney's one-page J interpreter.

mark_l_watson|6 months ago

The commented longer program listing was fun to read.

coderatlarge|6 months ago

can it execute the y-combinator?

f1shy|6 months ago

I’m pretty sure does not handle TCO… so probably not, unless with a huge stack.

spyrja|6 months ago

It doesn't appear to, but you could always add this to the included common.lisp file:

  (define Y (lambda (f) (lambda args ((f (Y f)) . args))))