Skip to content

Comment on Gödel, Escher, Elisp: The Beauty of Macros

Comments

If macros can implement arbitrary language features then how come elisp has never built a type system?

If macros can implement arbitrary language features

Not really your question--others have provided examples of type systems as macros--but they can't, they can only do local rewrites. You couldn't, for example, express mutation or non-local control flow if you didn't have them already; On the expressive power of programming languages [0] is rather theoretical but does set out the boundary of what macros can and can't do. That they're local means everyone has to buy into your type system if you want it to be a macro, though.

[0] https://www.sciencedirect.com/science/article/pii/0167642391... though https://www.youtube.com/watch?v=43XaZEn2aLc might be a useful walkthrough of the ideas being presented

I would expect you can.

lexilambda created Typed Racket on top of Racket. https://github.com/racket/typed-racket

Another approach, using macro expansion to perform the type checking: https://docs.racket-lang.org/turnstile/

Turnstile relies on the fact that in Racket, you can have identifier macros [1] which can be expanded in pretty much any location (except binding, naturally). Racket is unique in this regard. Clojure has a mechanism to get roughly the same thing, but it's complicated. [2]

1: https://docs.racket-lang.org/guide/pattern-macros.html#%28pa...

2: https://lambdaland.org/files/2024_ecoop_type_tailoring.pdf

Typed racket too, might I add. I just imagine static typing around stable core APIs would help users understand how eglot and vertico compare to prior art. The way I learned how the completion stack works was to ask claude to show me what the elisp entrypoints would look like if implemented in typescript. It's not because I'm unfamiliar with lisp, I'm not, it's just easier to reason with the world in terms of data structures and their contracts.

CL is the big cousin of Elisp, almost.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.