I have recovered the original example. Let's consider

    Integer.digits(1) # function
    defmodule M do
      Integer.is_odd(1) # macro
    end

Elixir says (my emphasis)

** (CompileError) foo.ex:4: you must require Integer before invoking *the
macro Integer.is_odd/1*
    (elixir) src/elixir_dispatch.erl:97: :elixir_dispatch.dispatch_require/6

So, according to the message, inside M the compiler has Integer compiled
and knows that Integer.is_odd/1 is a macro, the message says so!

If the true purpose of require was to ensure the module is compiled to know
its macros, that code should run, shouldn't it? Integer is compiled, I made
sure in a different way, the macros are known, so it should run. But it
doesn't run, so there's something more :).

>From a user's perspective, require is really saying "I want to use the
macros of this module", and Elixir may need to compile the module in order
to be aware of the macros the user has said they want to use if not already
compiled, but that is internal.

As a side comment, the docs also tell you that macro expansion happens at
compile time.

-- 
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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAM%3DYcdgnyEpyYLOjbOK%2BrkY7X%3DgL%3D4m_sXZf0xH5E%3DnL793nZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to