Get the latest tech news

Fennel libraries as single files (2023)


I’m pleased to announce that most of my libraries for fennel are now shipped as single files! It was a long-standing issue with Fennel for me, as there was no clear way to ship both macros and functions in the same file, but after some experimentation, I figured out a way.

We’ll add two macros defmulti, which given a name and a dispatch fn will create a local variable by itself, and defmethod which will act the same as add-method except it will construct the anonymous function for us. So I made a hack, that while splicing the library code scans for any occurrences of the(local lib-name (or ... pattern, and replaces it with the name used in the or expression, without checking.... And as the final change, we need to make that the fennel.searcher properly sets up macro-loaded in order to ditch the awkward(doto :lib require) thing.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Fennel Libraries

Fennel Libraries

Photo of Single Files

Single Files