BQN "Macros" with •Decompose (2023)
saltysylvi.github.io·4h·
Discuss: Hacker News

02/04/2023

Using •Decompose to create functions with access to the syntax tree of their arguments.


I just learned about the BQN system function •Decompose, and it’s really cool. As its name suggests, •Decompose breaks down a compound function, giving access to the parts of the function and specifying how they were combined. In other words, it grants us access to the syntax tree of a tacit function, sort of like a Lisp macro.

This is a powerful ability! It allows us to do dark magic in opposition to BQN’s “no magic” design philosophy.

There are limitations, however. •Decompose only does something useful with tacit functions. It doesn’t delay evaluation of its argument or anything like that. So i…

Similar Posts

Loading similar posts...