I\'m new to Erlang and am trying to program a bounded-buffer problem program. It is almost working, except for making sure the producers don\'t get too far ahead and overwr
There are only certain functions that can be used in a guard, see Guard Sequences in the Erlang manual. You can easily do what you need as follows:
buffer(Buf, NextWrite, NextRead) -> buffer(Buf, NextWrite, NextRead, array:size(Buf)).
buffer(Buf, NextWrite, NextRead, _) when NextWrite == NextRead ->
;
buffer(Buf, NextWrite, NextRead, BufSize) when (NextWrite - NextRead) == BufSize ->
;
buffer(Buf, NextWrite, NextRead, _) ->
.