Heavy macro use or not?

When I was working on DuckDispatch.jl, I realized that the user would need to define multiple copies of each of the required methods for a new DuckType. One for fallback, and one that unwraps the DuckType wrapper can calls the original function. It also has a reasonably complex syntax for declaring the supertype of a new DuckType and that supertype needs to match the methods you made exactly. Then, there is a whole other set of functions that you need to define if you want to dispatch on a DuckType.

A declarative DSL driven by macros allows me to make sure all of that is synced up and throw informative errors if the user messes something up.

I plan to document exactly what the macros are producing and make all of it public, but I would see it as highly inadvisable to circumvent the macro API.

2 Likes