We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents a73235a + 66019c3 commit 0d5bf3aCopy full SHA for 0d5bf3a
lib/elixir/lib/module.ex
@@ -51,18 +51,24 @@ defmodule Module do
51
When just a module is provided, the function/macro is assumed to be
52
`__before_compile__/1`.
53
54
- ### Example
+ Note: differently from `@after_compile`, the callback function/macro must
55
+ be placed in a separate module (because when the callback is invoked,
56
+ the current module does not yet exist).
57
- defmodule M do
- @before_compile __MODULE__
58
+ ### Example
59
60
+ defmodule A do
61
defmacro __before_compile__(_env) do
62
quote do
63
def hello, do: "world"
64
end
65
66
67
68
+ defmodule B do
69
+ @before_compile A
70
+ end
71
+
72
* `@behaviour` (notice the british spelling)
73
74
Specify an OTP or user-defined behaviour.
0 commit comments