WRITE
Evaluates code in a context of a new write transaction
Input stack: code
Output stack: result of code
evaluation
This instruction is the only way one can write to the database, meaning instructions like ASSOC are only possible in the context of a WRITE. If changes are to be saved, COMMIT has to be used as well. Read-transaction related instructions (such as RETR) can also be used.
The total number of simultaneous write transactions is limited to one.
PumpkinDB> ["hi" "there" ASSOC COMMIT] WRITE
Allocation
Will allocate for code
appended with an internal transaction end
marker instruction.
Errors
EmptyStack error if stack is less than one item on the stack.
DatabaseError error if there's a problem with underlying storage.
Decoding error error if the code is undecodable.
Tests
evals : [1] WRITE.
invalid_code : [1 WRITE] TRY UNWRAP 0x05 EQUAL?.
empty_stack : [WRITE] TRY UNWRAP 0x04 EQUAL?.
nested_writes_shouldnt_work_for_now : [[[] WRITE] TRY] WRITE UNWRAP 0x09 EQUAL?.
read_nested_writes_shouldnt_work_for_now : [[[] WRITE] TRY] READ UNWRAP 0x09 EQUAL?.