1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2026-08-15 13:34:53 +02:00
Files
cheatsheets/elixir-metaprogramming.md
Rico Sta. Cruz 511de900ba Formatting updates (#2133)
- Update some sheets which have very long sections
- Remove `layout: 2017/sheet` (everything has the same layout now)
- Remove outdated sheets
2024-04-03 18:30:24 +11:00

34 lines
717 B
Markdown

---
title: Elixir metaprogramming
category: Elixir
---
### Kernel
Most of these magic is defined in [Kernel.SpecialForms](http://devdocs.io/elixir/elixir/kernel.specialforms).
### Pseudo-variables
```elixir
__DIR__ # current dir
__MODULE__ # current module
__CALLER__ # caller of the function
```
### [`__ENV__`](http://devdocs.io/elixir/elixir/kernel.specialforms#__ENV__/0)
```elixir
Map.keys(__ENV__)
[:__struct__, :aliases, :context, :context_modules, :export_vars, :file,
:function, :functions, :lexical_tracker, :line, :macro_aliases, :macros,
:module, :requires, :vars]
```
```elixir
__CALLER__.module |> Module.definitions_in |> IO.inspect
```
```elixir
apply(Enum, :reverse, [[1, 2, 3]])
```