System interfaces

Table of contents

  1. Module time — time measurement
  2. Module sys — runtime system interface

Module time

Time measurement, pausing threads.

sleep(x)
Halt execution and continue after x seconds. The number x can be a float and thus fractional parts of a second are possible.
clock()
Start a new stop watch that returns time in seconds.
c = time.clock()
time.sleep(0.1)
print(c())
time()
Obtain Gregorian calendar date and UTC time.
# Format (each of type integer):
  [year, month, day, hour, minute, second]
# Example:
template = "{4(0)}-{2(0)}-{2(0)}T{2(0)}:{2(0)}:{2(0)}"
print(template % time.time())

Module sys

Interface to the runtime system.

argv
List of command-line arguments.
call(n,main,*argv)
Call main with a new call stack of size n. This is used to have unlimited recursion depth.
use sys

f = |n| 0 if n==0 else f(n-1)+1

function main
  print(f(100000))
end

sys.call(1000000,main)
exit(n)
Exit the program with integer return value n. Zero means success, other values indicate an error.
path
List of search paths for module loading, analogous to the environment variable PATH. This list can be changed freely and can contain relative paths. But note, that relative paths are problematic, if the current working directory changes. That path[0] should be the absolute path of the directory where argv[0] is found.