Documentation
¶
Overview ¶
Package system provides system interface primitives.
System Interface (R7RS 6.14) ¶
- command-line: return command-line arguments as list
- exit: terminate with exit status
- emergency-exit: terminate immediately without cleanup
Environment variable access (get-environment-variable, get-environment-variables) lives in the envvars extension. Implementation feature detection (features) lives in the introspection extension.
Time ¶
- current-second: current time as inexact seconds since epoch
- current-jiffy: high-resolution monotonic time
- jiffies-per-second: resolution of current-jiffy
Use Extension or AddToRegistry to register all primitives.
Package system provides system-level primitives.
Index ¶
- Variables
- func PrimCommandLine(mc machine.CallContext) error
- func PrimCurrentJiffy(mc machine.CallContext) error
- func PrimCurrentSecond(mc machine.CallContext) error
- func PrimEmergencyExit(mc machine.CallContext) error
- func PrimExit(mc machine.CallContext) error
- func PrimJiffiesPerSecond(mc machine.CallContext) error
- func SetCommandLine(args []string)
Constants ¶
This section is empty.
Variables ¶
var AddToRegistry = Builder.AddToRegistry
AddToRegistry registers all system primitives.
var Builder = registry.NewRegistryBuilder(addPrimitives)
Builder aggregates all system registration functions.
var Extension = registry.NewDescribedExtension("system", "System primitives: command-line, exit/emergency-exit, and time (current-second, current-jiffy, jiffies-per-second).", AddToRegistry)
Extension is the system extension.
var ProgramStartTime = time.Now()
ProgramStartTime is used for current-jiffy to measure elapsed time.
Functions ¶
func PrimCommandLine ¶
func PrimCommandLine(mc machine.CallContext) error
PrimCommandLine implements the (command-line) primitive per R7RS §6.14. Returns a list whose first element is the script name and the rest are script arguments. Falls back to os.Args when no script is being executed. Reading the host argv is gated as process:read, symmetric with the env:read gate on get-environment-variable: an embedder that installs a denying authorizer does not leak os.Args.
func PrimCurrentJiffy ¶
func PrimCurrentJiffy(mc machine.CallContext) error
PrimCurrentJiffy implements the (current-jiffy) primitive. Returns current time in jiffies since program start.
func PrimCurrentSecond ¶
func PrimCurrentSecond(mc machine.CallContext) error
PrimCurrentSecond implements the (current-second) primitive. Returns current time in seconds since Unix epoch.
func PrimEmergencyExit ¶
func PrimEmergencyExit(mc machine.CallContext) error
PrimEmergencyExit implements the (emergency-exit) primitive. Exits the program immediately without cleanup or finalization.
func PrimExit ¶
func PrimExit(mc machine.CallContext) error
PrimExit implements the (exit) primitive. Exits the program with an optional status code.
func PrimJiffiesPerSecond ¶
func PrimJiffiesPerSecond(mc machine.CallContext) error
PrimJiffiesPerSecond implements the (jiffies-per-second) primitive. Returns the number of jiffies per second (1 billion nanoseconds).
func SetCommandLine ¶ added in v1.5.0
func SetCommandLine(args []string)
SetCommandLine sets the command-line arguments returned by (command-line). The first element should be the script name, followed by script arguments.
Types ¶
This section is empty.