[erlang-bugs] Missing definitions in OTP Design Principles manual

Gunilla Arendt <>
Tue Oct 17 09:39:54 CEST 2006


Thank you for your comments.

As Ulf pointed out, the implementation of those functions are not
really relevant. In fact, they have intentionally been left out to
avoid cluttering the code unnecessarily. This is not made clear in
the text, however. I will add a clarification and maybe an example
implementation to be used when trying out the example.

Regards,
Gunilla, Erlang/OTP team

Kari Pahula wrote:
> I didn't find the definitions for alloc/1 and free/2 in OTP Design
> Principles manual version 5.5.1 (at
> http://www.erlang.org/doc/doc-5.5.1/doc/design_principles/part_frame.html)
> sections 1 and 2.
> 
> For example, in section 1.2 there was this example:
> 
> -module(ch1).
> -export([start/0]).
> -export([alloc/0, free/1]).
> -export([init/0]).
> 
> start() ->
>     spawn(ch1, init, []).
> 
> alloc() ->
>     ch1 ! {self(), alloc},
>     receive
>         {ch1, Res} ->
>             Res
>     end.
> 
> free(Ch) ->
>     ch1 ! {free, Ch},
>     ok.
> 
> init() ->
>     register(ch1, self()),
>     Chs = channels(),
>     loop(Chs).
> 
> loop(Chs) ->
>     receive
>         {From, alloc} ->
>             {Ch, Chs2} = alloc(Chs),
>             From ! {ch1, Ch},
>             loop(Chs2);
>         {free, Ch} ->
>             Chs2 = free(Ch, Chs),
>             loop(Chs2)
>     end.
> 
> It's not clear from this what alloc(Chs) and free(Ch, Chs) are
> supposed to do.
> _______________________________________________
> erlang-bugs mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-bugs
> 
> 




More information about the erlang-bugs mailing list