Raimo Niskanen raimo@REDACTED
Tue Apr 3 08:07:19 CEST 2001


you can't do arrays in Erlang. Since Erlang is a functional programming
language, mutable data structures (such as arrays) are not available in
the language. The closest resembling data structures are ETS tables and
the process dictionary. Both are accessed through BIFs (Built In
Functions). The process dictionary can be quite a fast array if it is
not too big.

... and semaphores do not exist either, since Erlang uses asynchronous
message passing between processes, and the processes can (almost) only
interact through this message passing. Therefore processes have no
common data and do not need semaphores to synchronize updates of common
data areas. Exception: ETS tables can be common to several processes and
updates might need to be synchronized. This is often solved by feeding
all updates (using message passing) through one process - eliminating

If you really need a semaphore to control the access of e.g some
external resource, one can easily be written as a locker process that
holds the semaphore state and is accessed through message passing, or,
again, have one single process that controls the external resource.

I hope this information gives some clarity to you.

/ Raimo Niskanen, Ericsson UAB, Erlang/OTP

> Colégio Divina Providência wrote:
>     Dear Srs.
>      Please, I'm a graduate student of Computer Cienci in
> State of Santa Catarina Brazil, I need developer a Work of
> Erlang Language.
>     Wel,  I like know who I do array in Erlang?
>     and I need developer a work of producer and consumer whit erlang
> using semaphores
>     Please Reply me  and help-me..
>     Thangs ...
> Marcio Luiz Ferreira
> Studant of Computing Cience of University of FURB
> Fundation University Regionary of Blumeau  SC - Brasil
> My E.-mails are
> marciolf@REDACTED
> marcio_co@REDACTED
> codivina@REDACTED

More information about the erlang-questions mailing list