22 System

Module System contains some useful features for interacting with the host environment.

SOURCE NOTE: most of these come from r7rs.

— Applicative: get-current-second (get-current-second)

Applicative get-current-second returns the number of seconds elapsed since the UNIX/POSIX epoch (that is midnight January 1st, 1970, UTC).

NOTE: r7rs specifies TAI seconds, but for now we are sticking to POSIX here.

— Applicative: get-current-jiffies (get-current-jiffies)

Applicative get-current-jiffies returns the number of jiffies (fractions of a second) elapsed since an arbitrary epoch that may change in each run of the klisp interpreter. Applicative get-jiffies-per-second can be used to determine which fraction of a second a jiffy represents.

— Applicative: get-jiffies-per-second (get-jiffies-per-second)

Applicative get-jiffies-per-second returns a constant representing the number of jiffies that correspond to one second.

— Applicative: file-exists (file-exists string)

Predicate file-exists? checks to see if a file named string exists.

— Applicative: delete-file (delete-file string)

string should be the name/path for an existing file.

Applicative delete-file deletes the file named string. If it doesn’t exists or can’t be deleted, an error is signaled. The result returned by delete-file is inert.

— Applicative: rename-file (rename-file string1 string2)

string1 should be the name/path for an existing file, string2 should be the name/path for a non existing file.

Applicative rename-file renames the file named string1 to string2. If the file doesn’t exists or can’t be renamed for any reason, an error is signaled. The result returned by rename-file is inert.

SOURCE NOTE: this is missing from r7rs, it is taken from C, being quite similar to delete-file.

— Applicative: get-script-arguments (get-script-arguments)
— Applicative: get-interpreter-arguments (get-interpreter-arguments)

These applicatives return respectively the script and interpreter arguments. The script arguments are a list of the arguments passed to the klisp interpreter starting from (and including) the script name. The interpreter arguments are the complete list of arguments passed to the klisp interpreter (including the name of the interpreter as the first item in the list, the interpreter flag arguments and the script name and arguments.

— Applicative: defined-environment-variable? (defined-environment-variable? string)

Predicate defined-environment-variable? returns true iff string represents a defined envrionment variable.

— Applicative: get-environment-variable (get-environment-variable string)

Applicative get-environment-variable returns the value of the environment variable represented by string. If string doesn’t represent a defined environment variable an error is signaled.

— Applicative: get-environment-variables (get-environment-variables)

Applicative get-environment-variable returns an alist representing the defined environment variables and their values. The alist is a list of (variable . value) entries, where both variable and value are strings.