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.
Features ¶
- features: return list of implementation features
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: time, sleep, features, command line.", 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.
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.