[erlang-questions] How to do counters?

Jarrod Roberson jarrod@REDACTED
Mon Jun 29 19:18:15 CEST 2009


2009/6/29 Witold Baryluk <baryluk@REDACTED>

>
> Another way is using just presented examples, and registering them on
> different names, or not registering them at all (they will be only
> referenced by Pid returned from spawn).
>
> You can register it using something like that:
>
> start(X) ->
>  Pid = spawn(counter,loop,[0]),
>  Name = list_to_atom("counter_"++X),
>  register(Name, Pid),
>  ok.


actually this is what I was trying to accomplish my self, I just couldn't
figure how how.

I guess I need to send in the name in the inc, dec, current methods as well
then?


More information about the erlang-questions mailing list