[erlang-questions] Feedback for my first non-trivial Erlang program
Samuel
samuelrivas@REDACTED
Tue Dec 15 09:36:01 CET 2015
> It's only a very minor suggestion, but you have a number of constants that could be replaced with compiler macros. For example:
Even though that is actually common practice, I have always found
difficult to see the benefit of it. Unless you want to pattern match
against those macros, using functions makes your code simpler as you
don't use the preprocessor (fewer concepts to manage). In general, try
to avoid the preprocessor as much as possible.
Simplicity is a benefit in itself, but by not using the preprocessor
you reap a few practical benefits:
* Those values are easily accessible from the shell when you are
debugging (if you export them or compile with export all for example)
* If you need to derive them in the future you have less to rewrite
(unless you want to have macros that expand to functions, which is
almost always bad idea)
* If you ever need to share them, you can do it just exporting the
functions instead of sharing an hrl file (which is also something to
avoid as it adds compilation dependencies that you wouldn't have
otherwise)
Best
--
Samuel
More information about the erlang-questions
mailing list