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
As Geoff Reedy has mentioned there are only few BIFS that are allowed in guards.
But the guardian parse transform library can be used to call any function in guards.
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, _) ->
.