binaries (byte array)

Roger Larsson roger.larsson@REDACTED
Mon Apr 24 14:28:55 CEST 2006


On måndag 24 april 2006 11.13, Kostis Sagonas wrote:
>  > Well, that seems handy (esp. in a compiler). The array
>  > update function seemed to be destructive though?
>
> Yes.
>
>  > So I guess my question is: do these arrays behave like
>  > ets tables or like terms? For example, what happens if
>  > array A is sent from P to Q, then updated in P -- will
>  > Q see the update?
>
> For most uses (i.e., when the array is big enough) the
> binary is stored off-heap, so for practical purposes the
> answer is "yes".  But this has not been our concern in
> uses so far.

Time to decide?
small -> on heap -> local
big -> off heap -> global
sent to other Erlang node -> local (but might be global on that node).

Or:
I have played with the idea to let the reference contain a generation
in cases like this. And to generate an exception if trying to access an array 
of the wrong generation.

Thus send the array (by reference but with generation) if you as
the creator guarantees that it will not change until the receiver
has processed the contents. (Syncrounous calls, or when giving up
ones own reference).
In other cases you is better of sending a process id for abstract
accesses...

/RogerL



More information about the erlang-questions mailing list