.TH compile 3erl "compiler 7.6.6" "Ericsson AB" "Erlang Module Definition" .SH NAME compile \- Erlang Compiler .SH DESCRIPTION .LP This module provides an interface to the standard Erlang compiler\&. It can generate either a new file, which contains the object code, or return a binary, which can be loaded directly\&. .SH DATA TYPES .nf .B option() = term() .br .fi .RS .LP See file/2 for detailed description .RE .SH EXPORTS .LP .B env_compiler_options() .br .RS .LP Return compiler options given via the environment variable \fIERL_COMPILER_OPTIONS\fR\&\&. If the value is a list, it is returned as is\&. If it is not a list, it is put into a list\&. .RE .LP .B file(File) .br .RS .LP Is the same as \fIfile(File, [verbose,report_errors,report_warnings])\fR\&\&. .RE .LP .B file(File, Options) -> CompRet .br .RS .LP Types: .RS 3 CompRet = ModRet | BinRet | ErrRet .br ModRet = {ok,ModuleName} | {ok,ModuleName,Warnings} .br BinRet = {ok,ModuleName,Binary} | {ok,ModuleName,Binary,Warnings} .br ErrRet = error | {error,Errors,Warnings} .br .RE .RE .RS .LP Compiles the code in the file \fIFile\fR\&, which is an Erlang source code file without the \fI\&.erl\fR\& extension\&. \fIOptions\fR\& determine the behavior of the compiler\&. .LP Returns \fI{ok,ModuleName}\fR\& if successful, or \fIerror\fR\& if there are errors\&. An object code file is created if the compilation succeeds without errors\&. It is considered to be an error if the module name in the source code is not the same as the basename of the output file\&. .LP Available options: .RS 2 .TP 2 .B \fIbasic_validation\fR\&: This option is a fast way to test whether a module will compile successfully\&. This is useful for code generators that want to verify the code that they emit\&. No code is generated\&. If warnings are enabled, warnings generated by the \fIerl_lint\fR\& module (such as warnings for unused variables and functions) are also returned\&. .RS 2 .LP Use option \fIstrong_validation\fR\& to generate all warnings that the compiler would generate\&. .RE .TP 2 .B \fIstrong_validation\fR\&: Similar to option \fIbasic_validation\fR\&\&. No code is generated, but more compiler passes are run to ensure that warnings generated by the optimization passes are generated (such as clauses that will not match, or expressions that are guaranteed to fail with an exception at runtime)\&. .TP 2 .B \fIbinary\fR\&: The compiler returns the object code in a binary instead of creating an object file\&. If successful, the compiler returns \fI{ok,ModuleName,Binary}\fR\&\&. .TP 2 .B \fIbin_opt_info\fR\&: The compiler will emit informational warnings about binary matching optimizations (both successful and unsuccessful)\&. For more information, see the section about bin_opt_info in the Efficiency Guide\&. .TP 2 .B \fI{compile_info, [{atom(), term()}]}\fR\&: Allows compilers built on top of \fIcompile\fR\& to attach extra compilation metadata to the \fIcompile_info\fR\& chunk in the generated beam file\&. .RS 2 .LP It is advised for compilers to remove all non-deterministic information if the \fIdeterministic\fR\& option is supported and it was supplied by the user\&. .RE .TP 2 .B \fIcompressed\fR\&: The compiler will compress the generated object code, which can be useful for embedded systems\&. .TP 2 .B \fIdebug_info\fR\&: .RS 2 .LP Includes debug information in the form of Erlang Abstract Format in the \fIdebug_info\fR\& chunk of the compiled beam module\&. Tools such as Debugger, Xref, and Cover require the debug information to be included\&. .RE .RS 2 .LP \fIWarning\fR\&: Source code can be reconstructed from the debug information\&. Use encrypted debug information (\fIencrypt_debug_info\fR\&) to prevent this\&. .RE .RS 2 .LP For details, see beam_lib(3erl)\&. .RE .TP 2 .B \fI{debug_info, {Backend, Data}}\fR\&: .RS 2 .LP Includes custom debug information in the form of a \fIBackend\fR\& module with custom \fIData\fR\& in the compiled beam module\&. The given module must implement a \fIdebug_info/4\fR\& function and is responsible for generating different code representations, as described in the \fIdebug_info\fR\& under beam_lib(3erl)\&. .RE .RS 2 .LP \fIWarning\fR\&: Source code can be reconstructed from the debug information\&. Use encrypted debug information (\fIencrypt_debug_info\fR\&) to prevent this\&. .RE .TP 2 .B \fI{debug_info_key,KeyString}\fR\&: .TP 2 .B \fI{debug_info_key,{Mode,KeyString}}\fR\&: .RS 2 .LP Includes debug information, but encrypts it so that it cannot be accessed without supplying the key\&. (To give option \fIdebug_info\fR\& as well is allowed, but not necessary\&.) Using this option is a good way to always have the debug information available during testing, yet protecting the source code\&. .RE .RS 2 .LP \fIMode\fR\& is the type of crypto algorithm to be used for encrypting the debug information\&. The default (and currently the only) type is \fIdes3_cbc\fR\&\&. .RE .RS 2 .LP For details, see beam_lib(3erl)\&. .RE .TP 2 .B \fIencrypt_debug_info\fR\&: .RS 2 .LP Similar to the \fIdebug_info_key\fR\& option, but the key is read from an \fI\&.erlang\&.crypt\fR\& file\&. .RE .RS 2 .LP For details, see beam_lib(3erl)\&. .RE .TP 2 .B \fIdeterministic\fR\&: Omit the \fIoptions\fR\& and \fIsource\fR\& tuples in the list returned by \fIModule:module_info(compile)\fR\&, and reduce the paths in stack traces to the module name alone\&. This option will make it easier to achieve reproducible builds\&. .TP 2 .B \fImakedep\fR\&: Produces a Makefile rule to track headers dependencies\&. No object file is produced\&. .RS 2 .LP By default, this rule is written to \fI\&.Pbeam\fR\&\&. However, if option \fIbinary\fR\& is set, nothing is written and the rule is returned in \fIBinary\fR\&\&. .RE .RS 2 .LP For example, if you have the following module: .RE .LP .nf -module(module). -include_lib("eunit/include/eunit.hrl"). -include("header.hrl"). .fi .RS 2 .LP The Makefile rule generated by this option looks as follows: .RE .LP .nf module.beam: module.erl \\ /usr/local/lib/erlang/lib/eunit/include/eunit.hrl \\ header.hrl .fi .TP 2 .B \fImakedep_side_effect\fR\&: The dependecies are created as a side effect to the normal compilation process\&. This means that the object file will also be produced\&. This option override the \fImakedep\fR\& option\&. .TP 2 .B \fI{makedep_output, Output}\fR\&: Writes generated rules to \fIOutput\fR\& instead of the default \fI\&.Pbeam\fR\&\&. \fIOutput\fR\& can be a filename or an \fIio_device()\fR\&\&. To write to stdout, use \fIstandard_io\fR\&\&. However, if \fIbinary\fR\& is set, nothing is written to \fIOutput\fR\& and the result is returned to the caller with \fI{ok, ModuleName, Binary}\fR\&\&. .TP 2 .B \fI{makedep_target, Target}\fR\&: Changes the name of the rule emitted to \fITarget\fR\&\&. .TP 2 .B \fImakedep_quote_target\fR\&: Characters in \fITarget\fR\& special to make(1) are quoted\&. .TP 2 .B \fImakedep_add_missing\fR\&: Considers missing headers as generated files and adds them to the dependencies\&. .TP 2 .B \fImakedep_phony\fR\&: Adds a phony target for each dependency\&. .TP 2 .B \fI\&'P\&'\fR\&: Produces a listing of the parsed code, after preprocessing and parse transforms, in the file \fI\&.P\fR\&\&. No object file is produced\&. .TP 2 .B \fI\&'E\&'\fR\&: Produces a listing of the code, after all source code transformations have been performed, in the file \fI\&.E\fR\&\&. No object file is produced\&. .TP 2 .B \fI\&'S\&'\fR\&: Produces a listing of the assembler code in the file \fI\&.S\fR\&\&. No object file is produced\&. .TP 2 .B \fIreport_errors/report_warnings\fR\&: Causes errors/warnings to be printed as they occur\&. .TP 2 .B \fIreport\fR\&: A short form for both \fIreport_errors\fR\& and \fIreport_warnings\fR\&\&. .TP 2 .B \fIreturn_errors\fR\&: If this flag is set, \fI{error,ErrorList,WarningList}\fR\& is returned when there are errors\&. .TP 2 .B \fIreturn_warnings\fR\&: If this flag is set, an extra field, containing \fIWarningList\fR\&, is added to the tuples returned on success\&. .TP 2 .B \fIwarnings_as_errors\fR\&: Causes warnings to be treated as errors\&. This option is supported since R13B04\&. .TP 2 .B \fIreturn\fR\&: A short form for both \fIreturn_errors\fR\& and \fIreturn_warnings\fR\&\&. .TP 2 .B \fIverbose\fR\&: Causes more verbose information from the compiler, describing what it is doing\&. .TP 2 .B \fI{source,FileName}\fR\&: Overrides the source file name as presented in \fImodule_info(compile)\fR\& and stack traces\&. .TP 2 .B \fI{outdir,Dir}\fR\&: Sets a new directory for the object code\&. The current directory is used for output, except when a directory has been specified with this option\&. .TP 2 .B \fIexport_all\fR\&: Causes all functions in the module to be exported\&. .TP 2 .B \fI{i,Dir}\fR\&: Adds \fIDir\fR\& to the list of directories to be searched when including a file\&. When encountering an \fI-include\fR\& or \fI-include_lib\fR\& directive, the compiler searches for header files in the following directories: .RS 2 .TP 2 * \fI"\&."\fR\&, the current working directory of the file server .LP .TP 2 * The base name of the compiled file .LP .TP 2 * The directories specified using option \fIi\fR\&; the directory specified last is searched first .LP .RE .TP 2 .B \fI{d,Macro}\fR\&: .TP 2 .B \fI{d,Macro,Value}\fR\&: Defines a macro \fIMacro\fR\& to have the value \fIValue\fR\&\&. \fIMacro\fR\& is of type atom, and \fIValue\fR\& can be any term\&. The default \fIValue\fR\& is \fItrue\fR\&\&. .TP 2 .B \fI{parse_transform,Module}\fR\&: Causes the parse transformation function \fIModule:parse_transform/2\fR\& to be applied to the parsed code before the code is checked for errors\&. .TP 2 .B \fIfrom_asm\fR\&: The input file is expected to be assembler code (default file suffix "\&.S")\&. Notice that the format of assembler files is not documented, and can change between releases\&. .TP 2 .B \fIfrom_core\fR\&: The input file is expected to be core code (default file suffix "\&.core")\&. Notice that the format of core files is not documented, and can change between releases\&. .TP 2 .B \fIno_spawn_compiler_process\fR\&: By default, all code is compiled in a separate process which is terminated at the end of compilation\&. However, some tools, like Dialyzer or compilers for other BEAM languages, may already manage their own worker processes and spawning an extra process may slow the compilation down\&. In such scenarios, you can pass this option to stop the compiler from spawning an additional process\&. .TP 2 .B \fIno_strict_record_tests\fR\&: This option is not recommended\&. .RS 2 .LP By default, the generated code for operation \fIRecord#record_tag\&.field\fR\& verifies that the tuple \fIRecord\fR\& has the correct size for the record, and that the first element is the tag \fIrecord_tag\fR\&\&. Use this option to omit the verification code\&. .RE .TP 2 .B \fIno_error_module_mismatch\fR\&: Normally the compiler verifies that the module name given in the source code is the same as the base name of the output file and refuses to generate an output file if there is a mismatch\&. If you have a good reason (or other reason) for having a module name unrelated to the name of the output file, this option disables that verification (there will not even be a warning if there is a mismatch)\&. .TP 2 .B \fI{no_auto_import,[{F,A}, \&.\&.\&.]}\fR\&: Makes the function \fIF/A\fR\& no longer being auto-imported from the \fIerlang\fR\& module, which resolves BIF name clashes\&. This option must be used to resolve name clashes with BIFs auto-imported before R14A, if it is needed to call the local function with the same name as an auto-imported BIF without module prefix\&. .LP .RS -4 .B Note: .RE As from R14A and forward, the compiler resolves calls without module prefix to local or imported functions before trying with auto-imported BIFs\&. If the BIF is to be called, use the \fIerlang\fR\& module prefix in the call, not \fI{no_auto_import,[{F,A}, \&.\&.\&.]}\fR\&\&. .RS 2 .LP If this option is written in the source code, as a \fI-compile\fR\& directive, the syntax \fIF/A\fR\& can be used instead of \fI{F,A}\fR\&, for example: .RE .LP .nf -compile({no_auto_import,[error/1]}). .fi .TP 2 .B \fIno_auto_import\fR\&: Do not auto-import any functions from \fIerlang\fR\& module\&. .TP 2 .B \fIno_line_info\fR\&: Omits line number information to produce a slightly smaller output file\&. .TP 2 .B \fI{extra_chunks, [{binary(), binary()}]}\fR\&: Pass extra chunks to be stored in the \fI\&.beam\fR\& file\&. The extra chunks must be a list of tuples with a four byte binary as chunk name followed by a binary with the chunk contents\&. See beam_lib for more information\&. .RE .LP If warnings are turned on (option \fIreport_warnings\fR\& described earlier), the following options control what type of warnings that are generated\&. Except from \fI{warn_format,Verbosity}\fR\&, the following options have two forms: .RS 2 .TP 2 * A \fIwarn_xxx\fR\& form, to turn on the warning\&. .LP .TP 2 * A \fInowarn_xxx\fR\& form, to turn off the warning\&. .LP .RE .LP In the descriptions that follow, the form that is used to change the default value are listed\&. .RS 2 .TP 2 .B \fI{warn_format, Verbosity}\fR\&: Causes warnings to be emitted for malformed format strings as arguments to \fIio:format\fR\& and similar functions\&. .RS 2 .LP \fIVerbosity\fR\& selects the number of warnings: .RE .RS 2 .TP 2 * \fI0\fR\& = No warnings .LP .TP 2 * \fI1\fR\& = Warnings for invalid format strings and incorrect number of arguments .LP .TP 2 * \fI2\fR\& = Warnings also when the validity cannot be checked, for example, when the format string argument is a variable\&. .LP .RE .RS 2 .LP The default verbosity is \fI1\fR\&\&. Verbosity \fI0\fR\& can also be selected by option \fInowarn_format\fR\&\&. .RE .TP 2 .B \fInowarn_bif_clash\fR\&: This option is removed, it generates a fatal error if used\&. .LP .RS -4 .B Warning: .RE As from beginning with R14A, the compiler no longer calls the auto-imported BIF if the name clashes with a local or explicitly imported function, and a call without explicit module name is issued\&. Instead, the local or imported function is called\&. Still accepting \fInowarn_bif_clash\fR\& would make a module calling functions clashing with auto-imported BIFs compile with both the old and new compilers, but with completely different semantics\&. This is why the option is removed\&. .LP The use of this option has always been discouraged\&. As from R14A, it is an error to use it\&. .LP To resolve BIF clashes, use explicit module names or the \fI{no_auto_import,[F/A]}\fR\& compiler directive\&. .TP 2 .B \fI{nowarn_bif_clash, FAs}\fR\&: This option is removed, it generates a fatal error if used\&. .LP .RS -4 .B Warning: .RE The use of this option has always been discouraged\&. As from R14A, it is an error to use it\&. .LP To resolve BIF clashes, use explicit module names or the \fI{no_auto_import,[F/A]}\fR\& compiler directive\&. .TP 2 .B \fInowarn_export_all\fR\&: Turns off warnings for uses of the \fIexport_all\fR\& option\&. Default is to emit a warning if option \fIexport_all\fR\& is also given\&. .TP 2 .B \fIwarn_export_vars\fR\&: Emits warnings for all implicitly exported variables referred to after the primitives where they were first defined\&. By default, the compiler only emits warnings for exported variables referred to in a pattern\&. .TP 2 .B \fInowarn_shadow_vars\fR\&: Turns off warnings for "fresh" variables in functional objects or list comprehensions with the same name as some already defined variable\&. Default is to emit warnings for such variables\&. .TP 2 .B \fInowarn_unused_function\fR\&: Turns off warnings for unused local functions\&. Default is to emit warnings for all local functions that are not called directly or indirectly by an exported function\&. The compiler does not include unused local functions in the generated beam file, but the warning is still useful to keep the source code cleaner\&. .TP 2 .B \fI{nowarn_unused_function, FAs}\fR\&: Turns off warnings for unused local functions like \fInowarn_unused_function\fR\& does, but only for the mentioned local functions\&. \fIFAs\fR\& is a tuple \fI{Name,Arity}\fR\& or a list of such tuples\&. .TP 2 .B \fInowarn_deprecated_function\fR\&: Turns off warnings for calls to deprecated functions\&. Default is to emit warnings for every call to a function known by the compiler to be deprecated\&. Notice that the compiler does not know about attribute \fI-deprecated()\fR\&, but uses an assembled list of deprecated functions in Erlang/OTP\&. To do a more general check, the Xref tool can be used\&. See also xref(3erl) and the function xref:m/1, also accessible through the function c:xm/1\&. .TP 2 .B \fI{nowarn_deprecated_function, MFAs}\fR\&: Turns off warnings for calls to deprecated functions like \fInowarn_deprecated_function\fR\& does, but only for the mentioned functions\&. \fIMFAs\fR\& is a tuple \fI{Module,Name,Arity}\fR\& or a list of such tuples\&. .TP 2 .B \fInowarn_deprecated_type\fR\&: Turns off warnings for use of deprecated types\&. Default is to emit warnings for every use of a type known by the compiler to be deprecated\&. .TP 2 .B \fInowarn_removed\fR\&: Turns off warnings for calls to functions that have been removed\&. Default is to emit warnings for every call to a function known by the compiler to have been recently removed from Erlang/OTP\&. .TP 2 .B \fI{nowarn_removed, ModulesOrMFAs}\fR\&: Turns off warnings for calls to modules or functions that have been removed\&. Default is to emit warnings for every call to a function known by the compiler to have been recently removed from Erlang/OTP\&. .TP 2 .B \fInowarn_obsolete_guard\fR\&: Turns off warnings for calls to old type testing BIFs, such as \fIpid/1\fR\& and \fIlist/1\fR\&\&. See the Erlang Reference Manual for a complete list of type testing BIFs and their old equivalents\&. Default is to emit warnings for calls to old type testing BIFs\&. .TP 2 .B \fIwarn_unused_import\fR\&: Emits warnings for unused imported functions\&. Default is to emit no warnings for unused imported functions\&. .TP 2 .B \fInowarn_unused_vars\fR\&: By default, warnings are emitted for unused variables, except for variables beginning with an underscore ("Prolog style warnings")\&. Use this option to turn off this kind of warnings\&. .TP 2 .B \fInowarn_unused_record\fR\&: Turns off warnings for unused record types\&. Default is to emit warnings for unused locally defined record types\&. .TP 2 .B \fInowarn_nif_inline\fR\&: By default, warnings are emitted when inlining is enabled in a module that may load NIFs, as the compiler may inline NIF fallbacks by accident\&. Use this option to turn off this kind of warnings\&. .RE .LP Another class of warnings is generated by the compiler during optimization and code generation\&. They warn about patterns that will never match (such as \fIa=b\fR\&), guards that always evaluate to false, and expressions that always fail (such as \fIatom+42\fR\&)\&. .LP Those warnings cannot be disabled (except by disabling all warnings)\&. .LP .RS -4 .B Note: .RE The compiler does not warn for expressions that it does not attempt to optimize\&. For example, the compiler tries to evaluate \fI1/0\fR\&, detects that it will cause an exception, and emits a warning\&. However, the compiler is silent about the similar expression, \fIX/0\fR\&, because of the variable in it\&. Thus, the compiler does not even try to evaluate and therefore it emits no warnings\&. .LP .RS -4 .B Warning: .RE The absence of warnings does not mean that there are no remaining errors in the code\&. .LP .RS -4 .B Note: .RE All options, except the include path (\fI{i,Dir}\fR\&), can also be given in the file with attribute \fI-compile([Option,\&.\&.\&.])\fR\&\&. Attribute \fI-compile()\fR\& is allowed after the function definitions\&. .LP .RS -4 .B Note: .RE Before OTP 22, the option \fI{nowarn_deprecated_function, MFAs}\fR\& was only recognized when given in the file with attribute \fI-compile()\fR\&\&. (The option \fI{nowarn_unused_function,FAs}\fR\& was incorrectly documented to only work in a file, but it also worked when given in the option list\&.) Starting from OTP 22, all options that can be given in the file can also be given in the option list\&. .LP For debugging of the compiler, or for pure curiosity, the intermediate code generated by each compiler pass can be inspected\&. To print a complete list of the options to produce list files, type \fIcompile:options()\fR\& at the Erlang shell prompt\&. The options are printed in the order that the passes are executed\&. If more than one listing option is used, the one representing the earliest pass takes effect\&. .LP Unrecognized options are ignored\&. .LP Both \fIWarningList\fR\& and \fIErrorList\fR\& have the following format: .LP .nf [{FileName,[ErrorInfo]}]. .fi .LP \fIErrorInfo\fR\& is described later in this section\&. The filename is included here, as the compiler uses the Erlang pre-processor \fIepp\fR\&, which allows the code to be included in other files\&. It is therefore important to know to \fIwhich\fR\& file the line number of an error or a warning refers\&. .RE .LP .B forms(Forms) .br .RS .LP Is the same as \fIforms(Forms, [verbose,report_errors,report_warnings])\fR\&\&. .RE .LP .B forms(Forms, Options) -> CompRet .br .RS .LP Types: .RS 3 Forms = [Form] .br CompRet = BinRet | ErrRet .br BinRet = {ok,ModuleName,BinaryOrCode} | {ok,ModuleName,BinaryOrCode,Warnings} .br BinaryOrCode = binary() | term() .br ErrRet = error | {error,Errors,Warnings} .br .RE .RE .RS .LP Analogous to \fIfile/1\fR\&, but takes a list of forms (in the Erlang abstract format representation) as first argument\&. Option \fIbinary\fR\& is implicit, that is, no object code file is produced\&. For options that normally produce a listing file, such as \&'E\&', the internal format for that compiler pass (an Erlang term, usually not a binary) is returned instead of a binary\&. .RE .LP .B format_error(ErrorDescriptor) -> chars() .br .RS .LP Types: .RS 3 ErrorDescriptor = errordesc() .br .RE .RE .RS .LP Uses an \fIErrorDescriptor\fR\& and returns a deep list of characters that describes the error\&. This function is usually called implicitly when an \fIErrorInfo\fR\& structure (described in section Error Information) is processed\&. .RE .LP .B output_generated(Options) -> true | false .br .RS .LP Types: .RS 3 Options = [term()] .br .RE .RE .RS .LP Determines whether the compiler generates a \fIbeam\fR\& file with the given options\&. \fItrue\fR\& means that a \fIbeam\fR\& file is generated\&. \fIfalse\fR\& means that the compiler generates some listing file, returns a binary, or merely checks the syntax of the source code\&. .RE .LP .B noenv_file(File, Options) -> CompRet .br .RS .LP Works like file/2, except that the environment variable \fIERL_COMPILER_OPTIONS\fR\& is not consulted\&. .RE .LP .B noenv_forms(Forms, Options) -> CompRet .br .RS .LP Works like forms/2, except that the environment variable \fIERL_COMPILER_OPTIONS\fR\& is not consulted\&. .RE .LP .B noenv_output_generated(Options) -> true | false .br .RS .LP Types: .RS 3 Options = [term()] .br .RE .RE .RS .LP Works like output_generated/1, except that the environment variable \fIERL_COMPILER_OPTIONS\fR\& is not consulted\&. .RE .SH "DEFAULT COMPILER OPTIONS" .LP The (host operating system) environment variable \fIERL_COMPILER_OPTIONS\fR\& can be used to give default compiler options\&. Its value must be a valid Erlang term\&. If the value is a list, it is used as is\&. If it is not a list, it is put into a list\&. .LP The list is appended to any options given to file/2, forms/2, and output_generated/2\&. Use the alternative functions noenv_file/2, noenv_forms/2, or noenv_output_generated/2 if you do not want the environment variable to be consulted, for example, if you are calling the compiler recursively from inside a parse transform\&. .LP The list can be retrieved with env_compiler_options/0\&. .SH "INLINING" .LP The compiler can do function inlining within an Erlang module\&. Inlining means that a call to a function is replaced with the function body with the arguments replaced with the actual values\&. The semantics are preserved, except if exceptions are generated in the inlined code\&. Exceptions are reported as occurring in the function the body was inlined into\&. Also, \fIfunction_clause\fR\& exceptions are converted to similar \fIcase_clause\fR\& exceptions\&. .LP When a function is inlined, the original function is kept if it is exported (either by an explicit export or if the option \fIexport_all\fR\& was given) or if not all calls to the function are inlined\&. .LP Inlining does not necessarily improve running time\&. For example, inlining can increase Beam stack use, which probably is detrimental to performance for recursive functions\&. .LP Inlining is never default\&. It must be explicitly enabled with a compiler option or a \fI-compile()\fR\& attribute in the source module\&. .LP To enable inlining, either use the option \fIinline\fR\& to let the compiler decide which functions to inline, or \fI{inline,[{Name,Arity},\&.\&.\&.]}\fR\& to have the compiler inline all calls to the given functions\&. If the option is given inside a \fIcompile\fR\& directive in an Erlang module, \fI{Name,Arity}\fR\& can be written as \fIName/Arity\fR\&\&. .LP Example of explicit inlining: .LP .nf -compile({inline,[pi/0]}). pi() -> 3.1416. .fi .LP Example of implicit inlining: .LP .nf -compile(inline). .fi .LP The option \fI{inline_size,Size}\fR\& controls how large functions that are allowed to be inlined\&. Default is \fI24\fR\&, which keeps the size of the inlined code roughly the same as the un-inlined version (only relatively small functions are inlined)\&. .LP Example: .LP .nf %% Aggressive inlining - will increase code size. -compile(inline). -compile({inline_size,100}). .fi .SH "INLINING OF LIST FUNCTIONS" .LP The compiler can also inline various list manipulation functions from the module \fIlist\fR\& in STDLIB\&. .LP This feature must be explicitly enabled with a compiler option or a \fI-compile()\fR\& attribute in the source module\&. .LP To enable inlining of list functions, use option \fIinline_list_funcs\fR\&\&. .LP The following functions are inlined: .RS 2 .TP 2 * lists:all/2 .LP .TP 2 * lists:any/2 .LP .TP 2 * lists:foreach/2 .LP .TP 2 * lists:map/2 .LP .TP 2 * lists:flatmap/2 .LP .TP 2 * lists:filter/2 .LP .TP 2 * lists:foldl/3 .LP .TP 2 * lists:foldr/3 .LP .TP 2 * lists:mapfoldl/3 .LP .TP 2 * lists:mapfoldr/3 .LP .RE .SH "PARSE TRANSFORMATIONS" .LP Parse transformations are used when a programmer wants to use Erlang syntax but with different semantics\&. The original Erlang code is then transformed into other Erlang code\&. .SH "ERROR INFORMATION" .LP The \fIErrorInfo\fR\& mentioned earlier is the standard \fIErrorInfo\fR\& structure, which is returned from all I/O modules\&. It has the following format: .LP .nf {ErrorLine, Module, ErrorDescriptor} .fi .LP \fIErrorLine\fR\& is the atom \fInone\fR\& if the error does not correspond to a specific line, for example, if the source file does not exist\&. .LP A string describing the error is obtained with the following call: .LP .nf Module:format_error(ErrorDescriptor) .fi .SH "SEE ALSO" .LP epp(3erl), erl_id_trans(3erl), erl_lint(3erl), beam_lib(3erl)