Elixir 中的保留属性是什么?
What are the reserved attributes in Elixir?
我刚刚花了很多时间调查为什么我的代码返回 nil:
defmodule Test
@impl 42
def foo, do: IO.inspect(@impl)
原来@impl
是保留属性名。好的,学习了但是,现在我想知道保留属性关键字的完整列表是什么?我找不到文档。我找到的最接近的是 this
Elixir has a handful of reserved attributes. Here are a few of them,
the most commonly used ones:
@moduledoc - provides documentation for the current module.
@doc - provides documentation for the function or macro that follows the attribute.
@behaviour - (notice the British spelling) used for specifying an OTP or user-defined behaviour.
@before_compile - provides a hook that will be invoked before the module is compiled. This makes it possible to inject functions inside
the module exactly before compilation.
这是标准库中模块 Module
的文档。
https://hexdocs.pm/elixir/Module.html#module-module-attributes
我刚刚花了很多时间调查为什么我的代码返回 nil:
defmodule Test
@impl 42
def foo, do: IO.inspect(@impl)
原来@impl
是保留属性名。好的,学习了但是,现在我想知道保留属性关键字的完整列表是什么?我找不到文档。我找到的最接近的是 this
Elixir has a handful of reserved attributes. Here are a few of them, the most commonly used ones:
@moduledoc - provides documentation for the current module. @doc - provides documentation for the function or macro that follows the attribute. @behaviour - (notice the British spelling) used for specifying an OTP or user-defined behaviour. @before_compile - provides a hook that will be invoked before the module is compiled. This makes it possible to inject functions inside
the module exactly before compilation.
这是标准库中模块 Module
的文档。
https://hexdocs.pm/elixir/Module.html#module-module-attributes