(newbie still) compile-time checks?

Mats Cronqvist <>
Tue Jul 11 09:49:22 CEST 2006


Jon Slenk wrote:
> hello,
> 
> I'm experimenting with the ping/pong code from the "Getting Started with 
> Erlang" tutorial and am wondering what happens if I were to mis-spell an 
> atom that is used in message passing. Are there ways to have something 
> like an enumerated type of atoms, so that if I use something outside of 
> the enumeration the compiler will tell me I made an error? Can Dialyzer 
> or some such tool figure out these kinds of possible typographical human 
> errors, or is the answer "extensive unit testing"? :-)

   i believe dialyzer will (at least often) find such typos in function calls. 
for message passing you'll probably have to resort to macros... a mistyped macro 
is caught be the compiler.
   of course, macros suck in a million different ways, so it's probably better 
to stick with unit testing.

   mats

crappymacro.hrl
-define(ONE,1).
-define(TWO,2).

bar.erl
-include("crappymacro.hrl").
foo ! ?ONE.

foo.erl
-include("crappymacro.hrl").
receive
   ?ONE -> one;
   ?TWO -> two



More information about the erlang-questions mailing list