I have some functions that generate arrays of lookup data at run time. It would be better to have them created at compile time via macros so I tried to convert them to macro code. The first layer was easy but I’m having trouble understanding how to call a macro from another macro to continue the ‘chaining’ of data build functions.

Although an Int is passed in it gets converted to an expression when passed to the nested function call, so I need to de-expression-ify that or something? And if I allow BitBuildMacro.getBitRow to accept Expr does that break calling it directly with Int values?

You’ll have to separate the creation of the macro expression and the logic itself, to be able to call getBitBlock from getBitBlocks, etc.

This doesn’t return the results you were expecting, but it seems like a problem in the logic you provided which I did not modify (except renaming points to blocks because it didn’t exist): http://try-haxe.mrcdk.com/#90831 (updated)

Ah, fantastic work and thanks. I see how it should be structured now. The data should be kept ‘pure’ until the very end when it gets dumped out as an expression. I had only used simple single function macros before so this threw me off.

The #if macro / #end around the sub-functions is just to keep them from being called outside the macro? I can see a way that a ‘pre-build’ of some data at compile time, and then a ‘lazy build’ during run time would come in handy by re-using the same _getBitxx calls.