Is there a way to do a global `use` during compilation in mix.exs?

27 views
Skip to first unread message

pragdave

unread,
Aug 27, 2017, 10:17:18 PM8/27/17
to elixir-lang-core

Let’s say I wanted to write a macro called defwombat that could be used just like defmodule but that compiled marsupials. And let’s pretend you thought it was a great idea.

What I’d like to be able to do is to write:

dave.ex:

defwombat Eric do

  # ... marsupial stuff
end

That is, I’d like to have defwombat available when compiling, just as if I’d written

use Wombat

defwombat Eric do

  # ... marsupial stuff
end

Is there any way currently of configuring this into mix? If not, and if I were to do the work, would it be considered?

Dave

José Valim

unread,
Aug 28, 2017, 3:01:56 AM8/28/17
to elixir-l...@googlegroups.com
We have no plans in adding such feature as it defeats one of the core features in macros in that they are always lexical.

If such feature is added, to know from where defwombat comes from, then I would need to look at the file and then remember to look at the mix.exs file or whatever other place that would be changing this global configuration.
--


José Valim
Skype: jv.ptec
Founder and Director of R&D
Reply all
Reply to author
Forward
0 new messages