Hello everybody. Another day, another proposal 😅
The problem: A lot of macros, when called, need to define a function - be it a private, helper function, or a final public function. This is very easy, when the macro is top-level (called directly in the module body). Unfortunately it's much harder to do, when the macro is called inside a function. Currently, there are two solutions: 1. Register a before_compile hook and accumulate data in some module attribute 2. Use Module.eval_quoted. Both solutions are rather ugly, possibly slow (especially in case of eval) and can lead to a very hard-to-debug code. Solution: I propose adding a Macro.define/3 function, that would allow to add a function or macro to a module under compilation, from any place. This way, the solution is obvious, does not require using any kind of eval and is local (unlike the module attribute solution proposed above). Michał. -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/599467ac-4032-4ce0-a230-2b2c1265c292%40Spark. For more options, visit https://groups.google.com/d/optout.
