Builtins module
This module contains built-in functions that are used by the Kaya run-time, functions required by the rest of the Prelude, and other fundamental functions.
It is automatically imported (via the Prelude module) unless
the -noprelude compiler option is used. All programs must
import this module, and most modules will need to.
Data types
- Builtins::Tainted<a> - Untrusted values (typically strings)
Exceptions
- AssertionFailure - An assertion failed
- Cant_Marshal_Exceptions - Exceptions may not be marshalled
- Cant_Reflect_Exceptions - Exceptions may not be reflected
- Divide_By_Zero - Tried to divide by zero.
- Getting_Tag_From_Non_Union - Tried to do a constructor
casestatement wrongly - IllegalIndex - Index is out-of-bounds or otherwise illegal
- InternalError - Thrown by the run-time system and foreign functions.
- Invalid_Circular_Structure - Marshal string describes an impossible structure
- Invalid_Function_Table_Hash - The function table has changed
- Invalid_Marshalling_ID - The unmarshal ID was invalid
- Invalid_Value - Invalid or uninitialised value
- Lookup_From_Non_Array - Tried to lookup in an array
- Loop_Return - Internal exception
- Loop_VoidReturn - Internal exception
- Missing_Case - Unexpected constructor in
casestatement - Negative_Array_Index - Array index must be non-negative
- NoNullsInStrings - Strings may not contain null bytes
- Not_Implemented - Not implemented yet
- Pattern_Matching_Assignment_Failure - Pattern matching assignment failed
- Project_From_Non_Union - Tried to read a field incorrectly
- Unguarded_Guard - Unexpected case in shorthand
- Wrong_Constructor - Tried to get a field from the wrong constructor
Functions
- Bool UTF8(String s) - Check whether a string contains UTF8 characters
- Float abs(Float x) - Return the magnitude of a floating-point number.
- Int abs(Int x) - Return the magnitude of an integer.
- Void assert(Bool test,String msg="Unspecified Assertion Failure") - Check the result of a test.
- Int byteLength(String s) - Length in bytes of a string
- Int compare(any x,any y) - Compare two values for "size"
- any copy(any x) - Copy a value
- String createString(Int len) - Creates a string with particular memory allocation
- Bool equal(any x,any y) - Equality check
- Bool equalStr(String x,String y) - Equality check for (Tainted) Strings
- Void exceptionBacktrace(Exception e) - Print the backtrace of an Exception.
- String exceptionMessage(Exception e) - Get a human-readable error message
- Void exit(Int code) - End the application immediately
- String fnName(Void(a) fn) - Internal standard library function
- String fnName(Int id) - Internal standard library function
- Int fnid(Void(a) fn) - Internal standard library function
- Int funtableHash() - Internal function.
- String getAddr(var a x) - Debugging function
- Char getIndex(String s,Int i) - Get a character from a String
- Ptr getVM() - Get a pointer to the Kaya VM
- Int hash(any x) - Hash a value
- Bool identical(a x,a y) - Return whether two values are identical.
- a identity(a val) - Returns a new reference to the original value.
- Bool inverse(Bool val) - Boolean NOT
- Bool isInitialised(var a x) - Checks if a value is initialised
- Int length(String s) - Length of a String
- String marshal(any x,Int id) - Marshal any value to a string
- Int memUsage(var a val) - Debugging function
- Int nameToId(String n) - Internal function.
- Bool null(Ptr p) - Checks if a foreign pointer is NULL
- Int rand() - Pseudo-random signed integer generator
- Bool runTimeChecking() - Is run-time checking enabled?
- Void s_getIndex_1() -
- Void setIndex(String s,Char c,Int i) - Change a character in a String in-place
- Int size(var [a] xs) - Length of an array
- Void srand(Int seed) - Seeds the random number generator
- Int strAlloc(String x) - Debugging function
- Int strHash(String s) - Get a numeric hash of a string.
- anything subvert(something x) - Subvert the type system.
- Void swap(var a x,var a y) - Swap the contents of two variables
- Void t_UTF8_1() -
- Void t_abs_f1() -
- Void t_abs_f2() -
- Void t_abs_f3() -
- Void t_abs_i1() -
- Void t_abs_i2() -
- Void t_abs_i3() -
- Void t_byteLength_es() -
- Void t_byteLength_fs() -
- Void t_compare_eq() -
- Void t_compare_gt() -
- Void t_compare_lt() -
- Void t_equal_no1() -
- Void t_equal_no2() -
- Void t_equal_no3() -
- Void t_equal_yes1() -
- Void t_equal_yes2() -
- Void t_equal_yes3() -
- Void t_hash_1() -
- Void t_identical_no1() -
- Void t_identical_yes1() -
- Void t_inverse_1() -
- Void t_inverse_2() -
- Void t_isInitialised_1() -
- Void t_length_es() -
- Void t_length_fs() -
- Void t_marshal_arr() -
- Void t_marshal_circ() -
- Void t_marshal_fail() -
- Void t_marshal_float() -
- Void t_marshal_int() -
- Void t_marshal_str() -
- Void t_rand_1() -
- Void t_setIndex_1() -
- Void t_size_earr() -
- Void t_size_narr() -
- Void t_srand_1() -
- Void t_strHash_1() -
- Void t_swap_1() -
- Void t_swap_2() -
- Void t_translate_es() -
- Void t_translate_fs() -
- Tainted<String> taint(String s) - Taint a string
- Void translate(var String s,Char(Char) rule) - Translate characters in a String
- any unmarshal(String x,Int id) - Unmarshal a string