Can you provide some actual code samples of before and after? Because while I don't have anything against Module.define/3, I am not sure it would actually be any better.
*José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Sat, Jun 17, 2017 at 4:17 PM, Michał Muskała <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/elixir-lang-core/599467ac-4032-4ce0-a230-2b2c1265c292%40Spark?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAGnRm4JTG-VQSTGGPEmOpn05fMa2RL-WLL8m2R0sFnk1jpFfkA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
