How is _before_compile_ used in the Kernel

Hi All,

So I understand how to use _before_compile but I wanted to dig deeper into how its actually working. My initial thoughts were that somewhere in the Kernel.defmodule macro it would read the value of the @before_compile annotation and I would see the macro been called after the block but I don’t see it used anywhere.

Can anyone point me in the direction of where this magic happens?

Also, are there any resources anywhere that go deeper into the elixir kernel and compiler. I am interested in understanding more how elixir works on the inside not just usage of the language.

Chris

1 Like

It seems Kernel.defmodule does delegate to :elixir_module.compile so you might want to look there. Afaik the compiler of elixir is written in erlang so you’d need to look here: https://github.com/elixir-lang/elixir/tree/master/lib/elixir/src

1 Like

Thanks I didn’t know where to look for this code, thanks for the pointer.