runmat-runtime 0.4.1

Core runtime for RunMat with builtins, BLAS/LAPACK integration, and execution APIs
Documentation
{
  "title": "clear",
  "category": "introspection",
  "keywords": [
    "clear",
    "workspace",
    "variables",
    "clear all",
    "command window"
  ],
  "summary": "Clear variables from the active workspace.",
  "references": [
    "https://www.mathworks.com/help/matlab/ref/clear.html"
  ],
  "gpu_support": {
    "elementwise": false,
    "reduction": false,
    "precisions": [],
    "broadcasting": "none",
    "notes": "Runs on the host CPU because it mutates the session workspace rather than array contents."
  },
  "fusion": {
    "elementwise": false,
    "reduction": false,
    "max_inputs": 16,
    "constants": "inline"
  },
  "requires_feature": null,
  "tested": {
    "unit": null,
    "integration": "command_controls::clear_command_clears_workspace_state"
  },
  "description": "`clear` removes variables from the active RunMat workspace. RunMat supports MATLAB-style `clear`, `clear all`, and named-variable forms such as `clear x` or `clear x y`, updating the session snapshot so removed variables disappear from subsequent workspace queries.",
  "behaviors": [
    "`clear` with no inputs clears all workspace variables created in the current session.",
    "`clear('all')` and command-form `clear all` are treated the same as bare `clear`.",
    "`clear x` removes the variable `x` while leaving other workspace bindings intact.",
    "Multiple names can be supplied as separate inputs or command-form tokens, for example `clear x y z`.",
    "After a successful clear, removed variables are no longer available to later statements and the workspace snapshot is refreshed so hosts can drop cleared bindings.",
    "Accepts variable names as string scalars, row character vectors, or string arrays. If any input is `all`, the entire workspace is cleared.",
    "Clearing a name that does not exist is a no-op.",
    "`clear` is a sink builtin and does not produce a meaningful output value."
  ],
  "examples": [
    {
      "description": "Clear the entire interactive workspace",
      "input": "x = 1;\ny = magic(3);\nclear",
      "output": "% x and y are removed from the workspace"
    },
    {
      "description": "Use MATLAB-style command form",
      "input": "a = 42;\nclear all",
      "output": "% a is removed from the workspace"
    },
    {
      "description": "Accessing a cleared variable raises an error",
      "input": "x = 7;\nclear;\nx",
      "output": "Undefined variable: x"
    },
    {
      "description": "Clear one variable while leaving others intact",
      "input": "x = 1;\ny = 2;\nclear x",
      "output": "% x is removed from the workspace while y remains defined"
    },
    {
      "description": "Clear multiple named variables in command form",
      "input": "a = 1;\nb = 2;\nc = 3;\nclear a b",
      "output": "% a and b are removed; c remains defined"
    }
  ],
  "faqs": [
    {
      "question": "Does `clear` remove every variable in the current session?",
      "answer": "Bare `clear` and `clear all` clear the full workspace. Named forms such as `clear x` remove only the specified bindings."
    },
    {
      "question": "Can I clear only one variable?",
      "answer": "Yes. Use `clear x` or `clear(\"x\")` to remove one variable, and pass multiple names to clear more than one binding in a single call."
    },
    {
      "question": "Does `clear` return anything?",
      "answer": "No meaningful value is returned. `clear` is a side-effecting builtin whose purpose is to mutate workspace state."
    },
    {
      "question": "Does `clear` affect plotting state or the console?",
      "answer": "No. `clear` only clears workspace variables. Use plotting commands such as `close all` for figures and `clc` for the visible console."
    },
    {
      "question": "Does GPU residency matter?",
      "answer": "No. `clear` operates on session bookkeeping, not on array kernels or provider-managed computations."
    }
  ],
  "links": [
    {
      "label": "who",
      "url": "./who"
    },
    {
      "label": "whos",
      "url": "./whos"
    },
    {
      "label": "clc",
      "url": "./clc"
    },
    {
      "label": "close",
      "url": "./close"
    }
  ],
  "source": {
    "label": "`crates/runmat-runtime/src/builtins/introspection/clear.rs`",
    "url": "https://github.com/runmat-org/runmat/blob/main/crates/runmat-runtime/src/builtins/introspection/clear.rs"
  },
  "gpu_behavior": [
    "`clear` performs host-side workspace mutation only. It does not launch GPU kernels, does not participate in fusion, and does not depend on acceleration providers."
  ]
}