3

Elixir metaprogramming cheatsheet

 2 years ago
source link: https://devhints.io/elixir-metaprogramming
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Kernel

Most of these magic is defined in Kernel.SpecialForms.

Pseudo-variables

__DIR__     # current dir
__MODULE__  # current module
__CALLER__  # caller of the function

__ENV__

Map.keys(__ENV__)
[:__struct__, :aliases, :context, :context_modules, :export_vars, :file,
 :function, :functions, :lexical_tracker, :line, :macro_aliases, :macros,
 :module, :requires, :vars]
__CALLER__.module |> Module.definitions_in |> IO.inspect
apply(Enum, :reverse, [[1, 2, 3]])

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK