Macro.Env record
A record that holds compile time environment information.
The current environment can be accessed at any time as
__ENV__. Inside macros, the caller environment can be
accessed as __CALLER__. It contains the following fields:
module- the current module name.file- the current file name as a binaryline- the current line as an integerfunction- a tuple as{ atom, integer}, where the first element is the function name and the seconds its arity. Returnsnilif not inside a functioncontext- the context of the environment. It can be nil (default context), inside a guard or inside an assignaliases- a list of two item tuples, where the first item is the aliased name and the second the actual namerequires- the list of required modulesfunctions- a list of functions imported from each modulemacros- a list of macros imported from each modulemacro_aliases- a list of aliases defined inside the current macrocontext_modules- a list of modules defined in the current contextvars- a list keeping all defined variables as { var, context }export_vars- a list keeping all variables to be exported in a construct (may be nil)lexical_tracker- PID to the lexical tracker which is responsible to keep user infolocal- the module to expand local functions to
Fields (and defaults)
- module: nil
- file: nil
- line: nil
- function: nil
- context: nil
- requires: nil
- aliases: nil
- functions: nil
- macros: nil
- macro_aliases: nil
- context_modules: nil
- vars: nil
- export_vars: nil
- lexical_tracker: nil
- local: nil
Summary
| in_guard?(record) | Returns whether the compilation environment is currently inside a guard |
| in_match?(record) | Returns whether the compilation environment is currently inside a match clause |
| location(record) | Returns a keyword list containing the file and line information as keys |
| stacktrace(record) | Returns the environment stacktrace |
Types ↑
name_arity :: {atom, non_neg_integer}
file :: binary
line :: non_neg_integer
aliases :: [{module, module}]
macro_aliases :: [{module, {integer, module}}]
context :: :match | :guard | nil
requires :: [module]
functions :: [{module, [name_arity]}]
macros :: [{module, [name_arity]}]
context_modules :: [module]
vars :: [{atom, atom | non_neg_integer}]
export_vars :: vars | nil
lexical_tracker :: pid
local :: module | nil
t :: {Macro.Env, module, file, line, name_arity, context, requires, aliases, functions, macros, aliases, context_modules, vars, export_vars, lexical_tracker, local}
options :: [module: module, file: file, line: line, function: name_arity, context: context, requires: requires, aliases: aliases, functions: functions, macros: macros, macro_aliases: aliases, context_modules: context_modules, vars: vars, export_vars: export_vars, lexical_tracker: lexical_tracker, local: local] | [{String.t, term}]