Qu

save

Builtin index · File I/O

save(path, name1, [name2, ...])

Input: path, name1, name2, ... · Output: no output

What it is

Writes the named variables — path (string, destination file) plus one or more variable names (strings) given explicitly as extra arguments — to a JSON file, each tagged with its own type.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
save(path, name1, [name2, ...])
path stringWrites the named variables — path (string, destination file) plus one or more variable names (strings) given explicitly as extra arguments — to a JSON file, each tagged with its own type.
name1 —not documented yet
name2, ... optional, repeatablenot documented yet
no output—

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

save("results.json", "x", "A")

from fundamentals

How it works

save(path, "name1", "name2", ...) — save specific top-level variables (by name, as strings — the same "name, not a value" convention pmap/spawn already use) to a JSON file. save_all(path) saves every top-level variable. Neither reaches into an active function's local frame — like MATLAB's own save, this operates on the base workspace. JSON so a saved file is human-readable/diffable, not a custom binary format (see the serde_json dependency's own Cargo.toml comment for the full reasoning). Worker/ Mutex/Semaphore values (live runtime handles, not data) fail the whole save clearly rather than silently dropping just that one variable.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.