[erlang-questions] Feedback for my first non-trivial Erlang program
Richard A. O'Keefe
Thu Dec 17 03:19:34 CET 2015
On the subject of macros vs functions for constants,
there is a third way.
(There should be a fourth way. Abstract patterns can
do *so* many nice things...)
For a constant that you don't want to use in a pattern
or guard, you can declare a function and then tell the
compiler to -inline it.
My advice would be:
- If you want to name something that must appear
in a pattern or guard, you have no choice but to
use a macro. (Until abstract patterns are
- Otherwise, always start by using plain functions.
Get the code working, then benchmark and profile it.
+ If performance of these functions is OK, stop worrying.
+ Try inlining and benchmark+profile again.
+++ It's generally better to try eliminating a calculation
than to micro-optimise it.
More information about the erlang-questions