Helpful commands for the erl shell
- Show all processes
pman:start()
- Show all applications
appmon:start()
Useful code snippets
Managing erlang build process
Erlang builds using Makefile
- Pittfalls:
- Always use tabs in Makefile
Otherwise following error may occur: Makefile:8: *** missing separator. Schluss.
- Example:
all:
erlc -pa . -o ebin/ src/*.erl test/*.erl
test: all
erl -pa ebin/ -eval 'eunit:test(testfile), init:stop().'
dialyze:
dialyzer src/*.erl test/*.erl
full: all test dialyze
Code Pitfalls
- Correct PID assignment
-
The code fragment
spawn(fun() -> something(self()) end)
does not pass the current PID in to the fun function, but instead
creates a new PID that is used. To achieve the correct behaviour, the
PID has to be assigned first:
P = self(), spawn(fun() -> something(P) end)
Analyzing erlang programs
The Dialyzer, a DIscrepancy AnalYZer for ERlang programs
- Pittfalls:
- In order to use dializer the first time, it has to be initialized by executing
"dialyzer --build_plt --apps erts kernel stdlib"
otherwise the following message may occur: "Could not find the PLT" and/or
"Byte code compiled with debug_info is needed to build the PLT"