Skip to main content

58  sys standard library

The sys module exposes process-level primitives: command-line argument access (argv), standard stream descriptor constants, null-pointer safety helpers, and process termination.

#use sys

58.1 Constants

  • sys::STDIN: Standard input descriptor (0).
  • sys::STDOUT: Standard output descriptor (1).
  • sys::STDERR: Standard error descriptor (2).

58.2 Command-line arguments

Function Signature Description
sys::argc Int Total count of command-line arguments passed to process
sys::argv Int => < String | > Safely retrieves argument by 0-based index as RamPN
sys::argv_string Int => String Retrieves argument string, returning "" on invalid index
sys::argv_matches Int, String => <> Tests whether argv[n] equals specified string
sys::raw_argv Int => < Addr | > Returns the C-string address or <--> for an invalid index
sys::argv(1)
   | file => io::out("Target file: " + file)
   | io::err("Usage: program <file>")

58.3 Address and pointer helpers

  • sys::addr_is_null(a: ptr) => <> tests whether a raw pointer is zero.
  • sys::addr_opt(a: ptr) => < Addr | > converts a raw pointer to an optional non-null address.
  • sys::c_str(raw: Addr) => String: Copies a null-terminated C string into a newly allocated, immutable Edva String.

58.4 Process termination

  • sys::exit(code: Int) => (): Terminates the host process immediately with status code code.