Ox Documentation

The Ox Standard Library

Overview
Handle Types
Constant Reference
Function Reference

Overview

Naming Convention

Naming Convention

Identifiers use snake_case/SNAKE_CASE. Boolean, numeric and string constants use UPPER_CASE, all other constants lower_case.

Handle Types

Complex Numbers

Complex Numbers

Construction

A complex number can be constructed in two ways:

1. By an arithmetic operation where one of the operands is the constant I. For example, to construct the complex number 2 − 3 i:

2 - 3 * I

2. By calling the complex function. For example, to construct the complex number −3 + 5 i:

complex(-3, 5)

Overloaded operators

The complex number type overloads the following unary operators:

+ -

The complex number type overloads the following binary operators:

* / + - *= /= += -=

Support functions

A complex number can be converted to a string with string. The string has the format:

(real, imaginary)

The following functions support complex numbers:

arg atan atanh conj cos cosh exp imag is_complex log real sin sinh sqrt tan tanh

Files

Threads

Constant Reference

args
BYTE_MAX
DEBUG
E
I
INF
NAN
NL
PI
SAFE_INT_MAX
stderr
STDERR
stdin
STDIN
stdout
STDOUT

args

A string list of program arguments.

BYTE_MAX

The maximum ordinal value of a byte, usually 255.

See also

ord, char.

DEBUG

true if debugging is enabled, otherwise false.

E

Euler's number, approximately 2.72.

I

The complex number i.

See also

Complex Numbers, complex.

INF

Infinity, the result of an overflowing mathematical operation.

See also

is_number.

NAN

Not-a-number, the result of an invalid mathematical operation.

See also

is_nan, is_number.

NL

A newline ("\n").

PI

Archimedes' constant, approximately 3.14.

SAFE_INT_MAX

The smallest positive integral number n that has the property n + 1 == n + 2. Usually equal to 9,007,199,254,740,991.

See also

is_safe_int.

stderr

The standard error stream.

See also

print_error, stdin. stdout,

STDERR

File descriptor of the standard error stream.

See also

STDIN. STDOUT,

stdin

The standard input stream.

See also

scan, stderr, stdout.

STDIN

File descriptor of the standard input stream.

See also

STDERR, STDOUT.

stdout

The standard output stream.

See also

print, stderr, stdin.

STDOUT

File descriptor of the standard output stream.

See also

STDERR, STDIN.

Function Reference

append
append_list
call
ceil
char
clear_file
close
close_file
complex
create_event
create_mutex
create_thread
die
dup
dup_file
error_message
error_number
fail
file_eof
file_error
file_no
find_key
floor
flush_file
fold
handle_type
has_key
imag
insert
insert_list
is_complex
is_event
is_file
is_finite
is_handle
is_int
is_mutex
is_nan
is_number
is_safe_int
is_thread
join_thread
lock_mutex
map
merge
move
number
open
open_file
ord
print
print_file
pulse_event
read
read_file
real
redir_file
remove
reopen_file
reset_event
round
scan
scan_file
seek
seek_file
set_error_number
set_key
signal_event
sleep
sort
sublist
submap
substr
succeed
string
tell
tell_file
thread_id
try_join_thread
type
unlock_mutex
unset_key
unused
wait_event
write
write_file

call

Calls a function with arguments from a list.

Usage

call(function, arguments)

function: A function to call.

arguments: A list of arguments to pass to function.

Return value

The return value of function.

See also

create_thread.

char

Returns a string from an ordinal byte value.

Usage

char(byte)

byte: Ordinal value of byte, an integer in the range 0 to BYTE_MAX.

Return value

A string of length 1 consisting of a byte with ordinal value byte.

See also

BYTE_MAX, ord.

clear_file

Clears the end-of-file and error indicators of a stream.

Usage

clear_file(file)

file: A file handle.

Return value

null.

See also

file_eof, file_error, open_file.

close

Closes a file descriptor.

Usage

close(fd)

file: A file descriptor.

Return value

On success, true. On failure, false, and a POSIX error number is set.

See also

open.

close_file

Closes a file.

Usage

close_file(file)

file: A file handle.

Return value

On success, true. On failure, false, and a POSIX error number is set.

Remarks

Calling close_file is optional, a file is automatically closed when there are no more references to the handle.

When a file is closed, any buffered data is flushed. This may cause close_file to temporarily block the calling thread.

After close_file has been called, the file handle is no longer valid and must not be used.

See also

flush_file, open_file.

complex

Constructs a complex number from two numbers.

Usage

complex(real, imag)

real: The real component.

imag: The imaginary component.

Return value

A complex number handle.

See also

Complex Numbers, i, imag, real.

create_event

Creates an event.

Usage

create_event([flags])

flags: Event flags, see the remarks.

Return value

On success, an event handle. On failure, null, and a POSIX error number is set.

Remarks

Events are used to send signals between threads.

The following flags are recognized:

CE_UNSIGNALED - Create an unsignaled event (default).
CE_SIGNALED - Create a signaled event.

Example

const a = create_event();

funct b()
{
    wait_event(a);
    print("event signaled");
}

const c = create_thread(b, []);
const d = create_thread(b, []);
unused((c, d));
sleep(1);
pulse_event(a);
sleep(1);
pulse_event(a);

See also

is_event, pulse_event, reset_event, signal_event, wait_event,

create_mutex

Creates a mutex.

Usage

create_mutex([flags])

flags: Mutex flags, see the remarks.

Return value

On success, a mutex handle. On failure, null, and a POSIX error number is set.

Remarks

A mutex (mutual-exclusive lock) is used to ensure only one thread at a time can execute a section of code. The function can create a standard or a reentrant mutex. When a mutex is reentrant it means a thread may lock it multiple times without causing an error.

The following flags are recognized:

CM_STANDARD - Create a standard mutex (default).
CM_REENTRANT - Create a reentrant mutex.

It is recommended to use a with statement for critical sections to ensure the mutex is unlocked, even if a runtime error occurs. See the example.

Example

const my_lock = create_mutex();

funct do_stuff()
{
    with (my_lock)
    { # enter critical section
        ...
    } # leave critical section
}

See also

is_mutex, lock_mutex, unlock_mutex,

create_thread

Creates a worker thread.

Usage

create_thread(function, arguments)

function: A function to call in the context of the new thread.

arguments: A list of arguments to pass to function.

Return value

On success, a thread handle. On failure, null, and a POSIX error number is set.

Remarks

A worker thread must always be joined, either explicitly by calling join_thread or try_join_thread, or implicitly when the handle is destroyed. Explicitly joining a thread is recommended, otherwise an error in the thread is ignored.

See also

call, fail, join_thread, sleep, succeed, thread_id, try_join_thread.

die

Terminates the program because of an error.

Usage

die([message[, end]])

message: An optional string to write to the standard error stream.

end: A string to write after message. Defaults to "\n" (a newline).

Return value

None.

Remarks

No cleanup is performed, die immediately terminates the interpreter process with an exit status indicating an error.

See also

fail.

dup

Duplicates a file descriptor.

Usage

dup(fd)

fd: A file descriptor.

Return value

On success, a file descriptor. On failure, null, and a POSIX error number is set.

See also

dup_file, open.

dup_file

Duplicates a file handle.

Usage

dup_file(file)

file: A file handle.

Return value

On success, a file handle. On failure, null, and a POSIX error number is set.

See also

dup, open_file, redir_file, reopen_file.

error_message

Returns an error message for a POSIX error number.

Usage

error_message([error_number])

error_number: An error number. If omitted, the calling thread's error number is implied.

Return value

On success, a string. On failure, null.

See also

error_number.

error_number

Returns the calling thread's error number.

Usage

error_number()

Return value

A number.

Remarks

An error number may be set when a function fails, as indicated by the documentation.

See also

error_message, set_error_number.

fail

Signals that the calling thread should exit abnormally.

Usage

fail([message[, end]])

message: An optional string to write to the standard error stream.

end: A string to write after message. Defaults to "\n" (a newline).

Return value

None.

Remarks

If called from a try statement, the finally body is executed.

See also

create_thread, die, succeed.

file_eof

Checks if the end-of-file indicator of a stream is set.

Usage

file_eof(file)

file: A file handle.

Return value

true or false.

See also

clear_file, read_file, open_file, scan_file.

file_error

Checks if the error indicator of a stream is set.

Usage

file_error(file)

file: A file handle.

Return value

true or false.

See also

clear_file, read_file, open_file, scan_file, write_file.

file_no

Returns the file descriptor of a file.

Usage

file_no(file)

file: A file handle.

Return value

On success, a file descriptor. On failure, null and a POSIX error number is set.

See also

open_file.

file_size

Returns the size of a file, in bytes.

Usage

file_size(file)

file: A file handle.

Return value

On success, a number. On failure, null.

See also

open_file.

find_key

Finds the key of a value in a map.

Usage

find_key(map, value, &key)

map: A map.
value: A value that may be in map.
key: An l-value which receives the associated key, if value exists in map.

Return value

If value is found in map, true. Otherwise, false.

Remarks

If multiple copies of value exist in the map, the key of the least recently added element is returned. For example, this prints "A" since "A" was added before "B":

const m = {"A" => 2, "B" => 2};
var key;
if (find_key(m, 2, &key));
    print(key);

See also

has_key.

fold

Folds a list.

Usage

fold(list, function[, initial])

list: A list to fold.

function: A function accepting two value arguments.

initial: Initial value. If omitted, the first element of list is the initial value.

Return value

If list is empty and initial is omitted, null. Otherwise, the result of the fold.

handle_type

Returns the type of a handle.

Usage

handle_type(handle)

handle: A handle.

Return value

A string. The following handle types are provided by the standard library:

"complex"
"event"
"file"
"mutex"
"thread"

Remarks

The returned string is provided by a library and may not be unique. To verify that a handle is of a particular type, call the corresponding is_handle_type function (e.g., is_file).

See also

is_complex, is_file, is_handle, is_mutex, is_thread, type.

has_key

Checks if a map has a key.

Usage

has_key(map, key)

map: A map.

key: Any value.

Return value

If key is a key of map, true. Otherwise, false.

See also

find_key, merge, set_key, unset_key.

imag

Returns the imaginary component of a complex number.

Usage

imag(complex)

complex: A complex number.

Return value

A number.

See also

Complex Numbers, complex, real.

insert

Inserts a value into a list.

Usage

insert(list, index, value)

list: A list.

index: Index of value after insertion.

value: A value to insert.

Return value

list with value inserted.

See also

append, insert_list, move, remove.

insert_list

Inserts a list into a list.

Usage

insert_list(list, index, elements)

list: A list to insert a list into.

index: Index of first element of elements after insertion.

elements: A list to insert.

Return value

list with elements inserted.

See also

append_list, insert, move, remove.

is_complex

Checks if a value is a complex number.

Usage

is_complex(value)

value: A value.

Return value

true or false.

See also

Complex Numbers, is_number.

is_event

Checks if a value is an event handle.

Usage

is_event(value)

value: A value.

Return value

true or false.

See also

create_event, is_handle.

is_file

Checks if a value is a file handle.

Usage

is_file(value)

value: A value.

Return value

true or false.

See also

is_handle, open_file.

is_handle

Checks if a value is a handle.

Usage

is_handle(value)

value: A value.

Return value

true or false.

See also

handle_type, is_complex, is_file, is_mutex, is_thread, type.

is_finite

Checks if a value is a finite number.

Usage

is_finite(value)

value: A value.

Return value

true or false.

See also

is_number.

is_int

Checks if a value is an integral number.

Usage

is_int(value)

value: A value.

Return value

true or false.

See also

is_number, is_safe_int.

is_mutex

Checks if a value is a mutex handle.

Usage

is_mutex(value)

value: A value.

Return value

true or false.

See also

create_mutex, is_handle.

is_nan

Checks if a value is a not-a-number.

Usage

is_nan(value)

value: A value.

Return value

true or false.

See also

is_number, NAN.

is_number

Checks if a value is a number.

Usage

is_number(value)

value: A value.

Return value

true or false.

Remarks

The function returns true for infinity and not-a-number.

See also

INF, is_complex, is_finite, is_int, is_nan, is_safe_int, NAN.

is_safe_int

Checks if a value is a "safe" integral number: an integral number in the range -SAFE_INT_MAX to SAFE_INT_MAX.

Usage

is_safe_int(value)

value: A value.

Return value

true or false.

See also

is_int, is_number, SAFE_INT_MAX.

is_thread

Checks if a value is a thread handle.

Usage

is_file(value)

value: A value.

Return value

true or false.

See also

create_thread, is_handle.

join_thread

Joins a worker thread.

Usage

join_thread(thread)

thread: A thread handle.

Return value

The thread's exit value.

Remarks

If the thread has already terminated, join_thread returns immediately. Otherwise, the calling thread is blocked until the thread has terminated.

If the thread terminated abnormally, an error occurs in the calling thread. If this is not desirable, call try_join_thread instead.

See also

create_thread, try_join_thread.

lock_mutex

Locks a mutex.

Usage

lock_mutex(mutex)

mutex: A mutex handle.

Return value

null.

Remarks

If the mutex is unlocked, the mutex is immediately locked. If the mutex is locked by another thread, the calling thread is suspended until it can lock the mutex. If the mutex is already locked by the calling thread, the lock count of the mutex is incremented.

Each call to lock_mutex must be balanced by a call to unlock_mutex.

See also

create_mutex, unlock_mutex.

map

Applies a function to each element in a list.

Usage

map(list, function)

list: A list.

function: A function accepting one value argument. The return value is the new value of the element.

Return value

The mapped list.

See also

fold.

merge

Merges two maps.

Usage

merge(map1, map2)

map1: A map.

map2: A map.

Return value

The merged map.

Remarks

In case of duplicate keys, the value from map2 is used.

See also

has_key, set_key, submap, unset_key.

move

Moves elements in a list.

Usage

move(list, from, to[, count])

list: A list with elements to move.

from: Index of first to element to move.

to: Index of first element to move after move.

count: Number of elements to move. Defaults to 1.

Return value

A copy of list with the elements moved.

See also

append, insert, insert_list, remove.

number

Converts a value to a number.

Usage

number(value)

value: A value.

Return value

A number:

If value is a number: value.

If value is a string with a decimal or scientific number representation: string converted to a number.

If value is a handle supporting conversion to number: conversion provided by the handle implementation.

For all other values: NAN.

See also

string.

open

Opens a file and connects it to a file descriptor.

Usage

open(pathname, flags[, mode])

pathname: Pathname of a file.
flags: Flags, see the remarks.
mode: Desired file mode, see the remarks.

Return value

On success, a file descriptor (a nonnegative integral number). On failure, null, and a POSIX error number is set.

Remarks

flags is a combination of the following constants:

o_append: Append to file.
o_create: Create the file if it does not exist.
o_read_only: Open for reading.
o_read_write: Open for reading and writing.
o_trunc: Truncate file.
o_write_only: Open for writing.

Use the bitwise OR operator (|) to combine flags.

flags must include of one o_read_only, o_write_only or o_read_write.

When flags include o_create, the mode argument specifies the file mode bits to apply to the new file.

The program is responsible for closing the file by calling close.

See also

close, open_file, read, write.

open_file

Opens a file for buffered reading and/or writing.

Usage

open_file(pathname[, mode])

pathname: Pathname of a file.
mode: Desired file mode, see the remarks.

Return value

On success, a file handle. On failure, null, and a POSIX error number is set.

Remarks

mode must be one of the following values:

of_read: Open file for reading. The file must exist. Default mode.
of_read_write: Open file for reading and writing. The file must exist.
of_trunc: Open file for writing. If the file exists, it is truncated, otherwise, it is created.
of_read_trunc: Open file for reading and writing. If the file exists, it is truncated, otherwise, it is created.
of_append: Open file for appending. If the file does not exist, it is created.
of_read_append: Open file for reading and appending. If the file does not exist, it is created.

The file is automatically closed when the returned handle has zero references.

See also

Files, clear_file, close_file, error_number, file_eof, file_error, file_mode, file_no, file_pathname, file_size, is_file, open, print_file, read_file, reopen_file, scan_file, seek_file, tell_file, write_file.

ord

Returns the ordinal value of a byte.

Usage

ord(string, n)

string: A string.

n: Index of byte.

Return value

The ordinal value of the nth byte of string, an integer in the range 0 to BYTE_MAX.

See also

BYTE_MAX. char.

print

Writes a string to the standard output stream.

Usage

print(string[, end])

string: A string to write.

end: A string to write after string. Defaults to "\n" (a newline).

Return value

The number of bytes written.

Remarks

The number of bytes written may be less than the length of string + end if an error occurs.

See also

print_error, print_file, scan, stdout. Writes a string to the standard error stream.

Usage

print_error(string[, end])

string: A string to write.

end: A string to write after string. Defaults to "\n" (a newline).

Return value

The number of bytes written.

Remarks

The number of bytes written may be less than the length of string + end if an error occurs.

See also

print, print_file, stderr. Writes a string to a file.

Usage

print_file(file, string[, end])

file: A file handle.

string: A string to write.

end: A string to write after string. Defaults to "\n" (a newline).

Return value

The number of bytes written.

Remarks

The number of bytes written may be less than the length of string + end if an error occurs.

See also

print, print_error, scan_file, write_file.

pulse_event

Resumes a single thread waiting for an event.

Usage

pulse_event(event)

event: An event handle.

Return value

null.

Remarks

If one or more threads are waiting for the event, one of the waiting threads is resumed. If there are no waiting threads, wait_event returns immediately the next time it is called.

pulse_event is accumulative, for each call a single thread is resumed.

The event must be unsignaled when pulse_event is called.

See also

create_event, reset_event, signal_event, wait_event.

real

Returns the real component of a complex number.

Usage

real(complex)

complex: A complex number.

Return value

A number.

See also

Complex Numbers, complex, imag.

read

Reads from a file descriptor.

Usage

read(fd, length)

fd: A file descriptor.

length: Number of bytes to read.

Return value

On success, a string. On failure, null, and a POSIX error number is set.

Remarks

read attempts to read length bytes from the file. The number of bytes read may be less than length if the end of the stream is reached, or an error occurs.

The number of bytes that can be read in a single operation may be limited by the implementation.

See also

open, seek, tell, write.

read_file

Reads from a file.

Usage

read_file(file, length)

file: A file handle.

length: Number of bytes to read.

Return value

A string.

Remarks

read_file attempts to read length bytes from the file. The number of bytes read may be less than length if the end of the stream is reached, or an error occurs.

The number of bytes that can be read in a single operation may be limited by the implementation.

See also

file_eof, file_error, open_file, scan_file, seek_file, tell_file, write_file.

redir_file

Redirects a file.

Usage

redir_file(from, to)

from: A file handle.
to: A file handle.

Return value

On success, true. On failure, false.

Remarks

redir_file redirects from so that reads and writes goes to to.

Example

const STDOUT_orig = dup_file(STDOUT);
const output = open_file("output.txt", of_trunc);
redir_file(STDOUT, output);
print("this goes to output.txt");
redir_file(STDOUT, STDOUT_orig);
print("this goes to the terminal again");

See also

dup_file, open_file, reopen_file.

remove

Removes a range of elements from a list.

Usage

remove(list, index[, count])

list: A list containing the elements to remove.

index: Index of first element to remove.

count: Number of elements to remove. Defaults to 1.

Return value

list with the elements removed.

See also

append, insert, move.

reopen_file

Reopens a file.

Usage

reopen_file(file, pathname[, mode])

file: A file handle.
pathname: A pathname. See the remarks.
mode: Desired file mode, see the remarks.

Return value

On success, true. On failure, false, and a POSIX error number is set.

Remarks

reopen_file is primarily used to redirect the standard streams (stdin, stdout, stderr) to a file.

If pathname is a string, the file pathname is opened in mode and the stream is associated with file.

If pathname is a null, the same file is reopened in mode.

See open_file for the possible values of mode. Defaults to the mode of file.

Example

if (!reopen_file(STDOUT, "output.txt"))
    fail(error_message());
print("this is written to output.txt");

See also

Files, dup_file, open_file, stderr, stdin, stdout.

reset_event

Sets an event to unsignaled.

Usage

reset_event(event)

event: An event handle.

Return value

null.

See also

create_event, pulse_event, signal_event, wait_event.

scan

Reads a line from the standard input stream.

Usage

scan()

Return value

A string.

Remarks

scan reads until a newline character is encountered, the newline character is included in the returned string. If the end of the stream is reached, or an error occurs, the returned string does not include a newline character.

It is also possible to read lines from the standard input stream with a for loop:

for line (stdin)
    print("You typed: " $ line, "");

The number of bytes that can be read in a single operation may be limited by the implementation.

See also

print, scan_file, stdin.

scan_file

Reads a line from a file.

Usage

scan_file(file)

file: A file handle.

Return value

A string.

Remarks

scan_file reads until a newline character is encountered. The newline character is included in the returned string. If the end of the stream is reached, or an error occurs, the returned string does not include a newline character.

It is also possible to read the lines of a file with a for loop:

const my_file = open_file("my_file");
if (is_file(my_file))
    for line (my_file)
        print(line, "");

The number of bytes that can be read in a single operation may be limited by the implementation.

See also

file_eof, file_error, open_file, read_file, scan

set_error_number

Sets the calling thread's error number.

Usage

set_error_number(number)

number: A number.

Return value

null.

See also

error_number.

set_key

Adds or updates a map key.

Usage

set_key(map, key, value)

map: A map.

key: A key to add or update.

value: A value to associate with the key.

Return value

map with the added or updated key.

See also

has_key, merge, submap, unset_key.

signal_event

Signals an event.

Usage

signal_event(event)

event: An event handle.

Return value

null.

Remarks

Any waiting threads are resumed. wait_event returns immediately for any calling threads.

See also

create_event, pulse_event, reset_event, wait_event.

sleep

Suspends the calling thread for a period of time.

Usage

sleep(secs)

secs: Number of seconds to sleep.

Return value

null

See also

create_thread.

sort

Sorts a list.

Usage

sort(list[, cmp_func)

list: A list to sort.

cmp_func: An optional function for comparing elements. The function must accept two arguments, the elements being compared. The function must return a number: 0 if the elements have the same order, a negative number if the first element should be ordered before the second element, or a positive number if the first element should be ordered after the second element. If omitted, the list is sorted in the standard order.

Return value

A sorted list.

See also

reverse.

string

Converts a value to a string.

Usage

string(value)

value: A value.

Return value

A string:

If value is null: "null".

If value is true: "true".

If value is false: "false".

If value is a finite number: a decimal or scientific representation of the number such as "-5", "3.25" or "-1.23e18".

If value is infinity: "-INF" (negative infinity) or "INF" (positive infinity).

If value is not-a-number: "NAN".

If value is a string: value.

If value is a handle supporting conversion to string: conversion provided by the handle implementation.

For all other values: "".

See also

number.

substr

Returns a range of bytes from a string.

Usage

substr(string, index, count)

string: A string to return bytes from.

index: Index of first byte to return.

count: Number of bytes to return.

Return value

A string of length count.

succeed

Signals that the calling thread should exit normally.

Usage

succeed([exit_value])

exit_value: The thread's exit value. Defaults to null.

Return value

None.

Remarks

If called from a try statement, the finally body is executed.

If called from the main thread, exit_value is unused.

See also

create_thread, fail.

thread_id

Returns the ID of a thread.

Usage

thread_id([thread])

thread: A thread handle. If omitted, the ID of the calling thread is returned.

Return value

The thread's ID, see the remarks.

Remarks

A thread ID is a integral number that uniquely identifies a thread. The main thread has ID 0, each created worker thread is assigned a successive ID (1, 2, 3, ...). Thread IDs are not reused.

See also

create_thread,

try_join_thread

Attempts to join a worker thread.

Usage

try_join_thread(thread, &exit_value)

thread: A thread handle.

exit_value: An l-value that receives the thread's exit value if the thread terminated normally.

Return value

If the thread terminated normally, true. If the thread terminated abnormally, false.

Remarks

If the thread has already terminated, try_join_thread returns immediately. Otherwise, the calling thread is blocked until the thread has terminated.

See also

create_thread, join_thread.

type

Returns the type of a value.

Usage

type(value)

value: A value.

Return value

One of the following values:

type_null
type_bool
type_number
type_string
type_list
type_map
type_funct
type_struct
type_handle

See also

handle_type.

unlock_mutex

Unlocks a mutex.

Usage

unlock_mutex(mutex)

mutex: A mutex handle.

Return value

null.

Remarks

The mutex must be locked by the calling thread. The lock count of the mutex is decremented. If the lock count is zero, the mutex is unlocked.

See also

create_mutex, lock_mutex.

unset_key

Removes a key from a map.

Usage

unset_key(map, key)

map: A map containing the key to remove.

key: A key to remove from map.

Return value

If key is a key of map, map with the key removed. Otherwise, map.

See also

merge, set_key.

unused

Does nothing.

Usage

unused(value)

value: Any value.

Return value

null.

Remarks

The function can be called to suppress "symbol unused" diagnostic messages:

funct a(b, c) {
    unused(c);
    return d(b);
}

wait_event

Waits for an event to become signaled.

Usage

wait_event(event)

event: An event handle.

Return value

null.

Remarks

If the event is already signaled, the function returns immediately. Otherwise, the calling thread is blocked until the event is signaled.

See also

create_event, pulse_event, reset_event, signal_event.

write

Writes to a file descriptor.

Usage

write(fd, string)

fd: A file descriptor.

string: A string to write.

Return value

On success, the number of bytes written, which may be less than the length of string if an error occurs. On failure, null and a POSIX error number is set.

See also

open, read, seek, tell.

write_file

Writes to a a file.

Usage

write_file(file, string)

file: A file handle.

string: A string to write.

Return value

The number of bytes written, which may be less than the length of string if an error occurs.

See also

close_file, file_error, flush_file, open_file, print_file, read_file, seek_file, tell_file.