`session` is a built-in global object for inspecting and managing Expr sessions.
A session stores root variables, user-defined functions, user-defined classes, and the last result for a named evaluation context.
| Property | Type | Description |
|---|---|---|
| `current` | string | Name of the active session. The fallback session uses an empty name. |
print(session.current);
Returns session names separated by new lines.
print(session.list());
Returns variables in the current session, one per line.
print(session.list_variables());
Returns built-in function names, one per line.
Returns built-in object constructor names, one per line.
Returns user-defined function names in the current session.
Returns user-defined class names in the current session.
Creates a new session named `name`, switches the current context to it, and returns an OK result. If the session already exists, returns an error result.
session.create('job1'); print(session.current); // job1
Deletes the session named `name` and returns an OK result if it existed.
session.delete('old_job');
Switches the current context to an existing session. If the session does not exist, an error is raised.
session.join('job1');
Switches the current context to the fallback empty-name session and returns an OK result.
session.leave();
Clears variables, user functions, and user classes from the current session. Built-in global objects are restored.
session.clear();
Returns `true` if `sessionName` contains `variableName`.
exists = session.has_variable('job1', 'part_count');