Lumesh Sys Module

wiki libs

Rust sys Module Documentation

Module Overview

Provides a core set of built-in functions related to environment variable operations for managing the runtime environment.

help sys

+-------------------------------------------------------------------------------------+
| KEY VALUE |
+=====================================================================================+
| has Builtin@has check if a variable is defined in current environment |
| env Builtin@env get root environment as a map |
| defined Builtin@defined check if a variable is defined in current environment |
| tree |
| set Builtin@set define a variable in root environment |
| err_codes Builtin@err_codes display runtime error codes |
| vars Builtin@vars get defined variables in current environment |
| discard Builtin@discard send data to /dev/null |
| print_tty Builtin@print_tty print control sequence to tty |
| quote Builtin@quote quote an expression |
| unset Builtin@unset undefine a variable in root environment |
+-------------------------------------------------------------------------------------+


2. env

  • Function: Get the list of variables in the top-level scope environment
  • Parameters: None
  • Return Value: A mapping structure of type Environment
  • Example: (env) → Returns all bindings in the top-level scope

3. vars

  • Function: Get the list of variables in the current environment
  • Parameters: None
  • Return Value: A hash table containing a mapping of (variable name → value)

4. set

  • Function: Define/modify a variable in the top-level scope
  • Parameters: (set name value)
    • name: A string type variable name
    • value: Any expression
  • Return Value: Expression::None
  • Error: Throws an exception if the number of parameters is not 2

5. unset

  • Function: Remove the definition of a variable in the top-level scope
  • Parameters: (unset name)
    • name: A string type variable name
  • Return Value: Expression::None
  • Error: Throws an exception if the number of parameters is not 1

6. defined

  • Function: Check if a variable is defined in the current and parent scopes
  • Parameters: (defined name)
    • name: A string type variable name
  • Return Value: Boolean type (true indicates defined)
  • Error: Throws an exception if the number of parameters is not 1

7. has

  • Function: Check if a variable is defined in the current scope
  • Parameters: (has name)
    • name: A string type variable name
  • Return Value: Boolean type (true indicates defined)
  • Error: Throws an exception if the number of parameters is not 1

1. err_codes

  • Function: Get the runtime error code table
  • Parameters: None
  • Return Value: A hash table containing a mapping of (error code → description)
  • Usage: Query error types during debugging

2. quote

  • Function: Create a reference to an expression (prevent evaluation)
  • Parameters: (quote expr)
    • expr: Any expression
  • Return Value: Quote type (contains an immutable reference to the original expression)
  • Error: Throws an exception if the number of parameters is not 1

3. print_tty

  • Function: Write control instructions to tty
  • Parameters: (print_tty expr)
    • String: Character expression
  • Return Value: None type
  • Error: Throws an exception if the number of parameters is not 1

4. discard

  • Function: Send data to /dev/null
  • Parameters: (discard expr)
    • expr: Any expression
  • Return Value: Quote type (contains an immutable reference to the original expression)