Skip to main content

Module repl

Module repl 

Source
Expand description

§OMG Language REPL

This module implements an interactive Read–Eval–Print Loop (REPL) for the OMG language. It allows users to type OMG code line by line, evaluate it immediately, and see results.

§Design

  • Provides prompts (>>> for fresh input, ... for continuation).
  • Tracks brace depth so users can enter multi-line blocks (e.g., function definitions, conditionals) before execution.
  • Preserves command history so new input can build upon previously defined variables and functions.
  • Executes code by writing it to a temporary .omg file and re-invoking the current binary with that file. This ensures consistency between REPL and script execution.
  • Supports graceful exit with exit or quit.

§Limitations

  • Because execution is performed by spawning a new process, performance is lower than a native in-process interpreter loop.
  • Output diffing (last_output) is used to only print new results between iterations, preventing repeated display of old output.

Functions§

repl_interpret
Run an interactive REPL for the OMG language.