A QuakeC program's words: a value per index from 0. A word never written is 0. Values
are floats, integers from -2^49 up to but not including 2^49, and binaries.
memory = QuakeC.Memory.from_list([1.0, 2.0])
memory = QuakeC.Memory.set(memory, 70_000, 3.0)
QuakeC.Memory.get(memory, 70_000)
#=> 3.0The memory is written in place and every copy of it sees every write, whichever copy
made it: the words are held in :atomics chunks of 65536 words, and the chunks and
the binaries in an ETS table. set/3 and put/3 may return a memory that reaches a new
chunk without a table lookup; an older copy reaches it through the table.
The table belongs to the process that made the memory: the memory works from any
process while that process lives, and delete/1 frees it sooner. copy/1 makes a
memory written apart from the original.
get_code/2 gives the same read as quoted code, for compiled programs to inline.
Summary
Functions
A memory holding the same values whose words are written apart from memory's.
Free the memory's table; neither it nor any copy of it may be used after.
Write integer or float value into count words from index; the memory to use from then on.
Memory holding values from index 0.
The word at index.
Code reading word index of memory, both quoted.
Copy count words of source from index from into target from index to, as they
stood before the copy (the ranges may overlap, and source may be target); the target
memory to use from then on.
Memory with no words written.
Write value at index: :ok, or a memory that reaches the chunk the word is in when
the write made it.
Write value at index; the memory to use from then on.
Types
Functions
A memory holding the same values whose words are written apart from memory's.
@spec delete(t()) :: :ok
Free the memory's table; neither it nor any copy of it may be used after.
@spec fill(t(), non_neg_integer(), non_neg_integer(), number()) :: t()
Write integer or float value into count words from index; the memory to use from then on.
Memory holding values from index 0.
@spec get(t(), non_neg_integer()) :: term()
The word at index.
Code reading word index of memory, both quoted.
@spec move(t(), non_neg_integer(), t(), non_neg_integer(), non_neg_integer()) :: t()
Copy count words of source from index from into target from index to, as they
stood before the copy (the ranges may overlap, and source may be target); the target
memory to use from then on.
@spec new() :: t()
Memory with no words written.
@spec put(t(), non_neg_integer(), term()) :: :ok | t()
Write value at index: :ok, or a memory that reaches the chunk the word is in when
the write made it.
@spec set(t(), non_neg_integer(), term()) :: t()
Write value at index; the memory to use from then on.