We’ll start with a simple example and build a concurrent model of an everyday scene. Imagine I see four people out for a walk. There are two dogs and a large number of rabbits. The people are talking to each other, and the dogs want to chase the rabbits.
To simulate this in Erlang, we’d make four modules called
world. The code for
person would be in a file
person.erl and might look something like this:
init(Name) -> ...
The first line,
-module(person)., says that this file
contains code for the module called
person. This should
be the same as the filename (excluding the
extension). The module name must start with a small letter. ...