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

Kari Pahula kaol@REDACTED
Sun Oct 15 02:22:58 CEST 2006


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.



More information about the erlang-bugs mailing list