?MACHINE
is encountered by the
compiler, it
is expanded to the machine which is running the compiler,
not the machine for which the code is compiled. The latter is
almost always more useful.
c:c(File, 'P')
does produce a .P file, but yields an
ugly error message in the process.
epp
) to
hang or crash. (Checking is not done for macros which
exploit the fact that macros may end in a lone '?
' -
use of this feature is not recommended.)
-module(beamfel3). -export([handle_cast/2]). -record(state,{e1,e2}).or like this:
handle_cast({a,DpId},State) when State == #state{e1=true, e2=a} -> process_info(DpId);
handle_cast({a,DpId},State) when State == #state{e1=true, e2=b} -> process_info(DpId).
-module(beamfel2). -export([f/2]).This codegeneration error could cause the Erlang emulator to terminate with the message "Overrun heap and stack ...". This is now corrected. This has also been corrected in patch erl_077 for OTP R4B.
f({a,DpId},16#7fffffff) -> process_info(DpId);
f({a,DpId},16#80000000) -> process_info(DpId).
<
' operator was used in a body context
(Bool = Expr1 < Expr
), the compiler could crasch
or generate incorrect code. This has been corrected.
compile
module: compile:forms/1
and
compile:forms/2
, which are analogous to
compile:file/[1,2]
, but take a list of forms as
their first argument (such as is returned by the
function epp:parse_file/3
). The option
binary
is implicit; i.e., a binary is produced,
never an object code file. If a listing file is
requested (e.g., using the option 'E'), the module
name is taken as the file name.
if
and case
expressions when only
one branch can ever be selected.
f({'+',X,Y}=T) -> {X+Y,T}.This often makes it possible to avoid rebuilding a term which is already present but has no name, since it was matched with a complex pattern. It also makes it possible to rewrite the construction
f(X) when X == #rec{x=1, y=a} -> ...as
f(#rec{x=1, y=a} = X) -> ...In the absence of optimization for the former case, the latter case is more efficient.
asm
expects the input file to be
a previously produced Erlang assembler file (default
file suffix ".S"). Note that the format of assembler files
is not documented, and may change between releases - this
option is primarily for internal debugging use.
The asm
option only works for BEAM.
export_all
compilation option no longer produces one
warning for each function defined in a module; it produces
one single warning (since export_all
shouldn't be used
in production code).
dexp
and dpe
, which produce files with
extension "expand
" and "parteval
",
respectively. To pass these options to the compiler via
erlc
, prefix them with a '+'. For Beam, the new
options dcg
and dopt
produce files with
extension "codegen
" and "optimize
", respectively.
Two adjacent literal string tokens are concatenated into
one string at compile-time (actually, by the parser).
For example, "abc" "def"
becomes "abcdef"
.
The compiler directives -include(File)
and
-include_lib(File)
are available for including header
files.
Own Id: OTP-3051
f("prefix" ++ L) -> ...This is syntactic sugar for the equivalent, but harder to read
f([$p,$r,$e,$f,$i,$x | L]) -> ...