bakpakin / Fennel

Lua Lisp Language
https://fennel-lang.org
MIT License
2.42k stars 124 forks source link

[Feature Request] Global macro definitions #469

Closed alexmozaidze closed 10 months ago

alexmozaidze commented 10 months ago

Some projects require heavy use of some repetitive operations, and importing the same set of macros over and over again in almost every file is quite tiring. It would be useful to have some way of declaring global macros.

I see it being implemented as a new argument in fennel.dofile that determines which file(s) Fennel evaluates for macro definitions:

require "fennel".dofile("main.fnl", { globalMacros = { "macros/global.fnl" } })

And with that, main.fnl and every file main.fnl requires will have macros as defined in macros/global.fnl.

technomancy commented 10 months ago

Unfortunately this would be a pretty serious blow to the consistency and transparency that Fennel is built upon. We are not going to do this; you can read more about why here: https://fennel-lang.org/values#transparency