Manual: base

A base module that is extended into a main module by default. Not completely documented.

The contents of this base module are available immediately when a Lever runtime starts.

Most of the functions in the base module are built into the language runtime.

Table of contents ↑
Table of contents
01. Boolean Logic
02. Objects & Interfaces
03. Functions & Multimethods
04. Custom classes & objects
05. Primitives
06. String decoding & encoding & conversions
07. Path handling
08. Byte arrays
09. Basic I/O
10. Greenlets & Concurrency
11. Runtime
12. Modules
13. Logging
14. Errors and exceptions
15. Operators
16. Mathematic functions and interfaces
17. Random numbers and quantities
18. Miscellaneous
class null extends null
Constant, represents absence.

null always represents an absence of something.

null and false are the only values that produce false when converted into boolean values.

The definition of null is a bit weird because it's a legal class while being a constant.

As an internal detail, the null is an interface that is its own interface and parent.

01. Boolean Logic

The booleans false and true are the only instances of the bool interface.

false
Constant, represents falsehood.
true
Constant, represents truth.
class bool extends object
Interface of the true and false
+hash()
Booleans are hashable and can be used in a dictionary.

This hash function can be a bit of an oxymoron because in Lever constants and interfaces would have a hash anyway.

pointless?
+init(obj)
obj can be any value available.
returns false if obj is false or null, true otherwise.
Converts a value into a boolean if it already isn't. Returns 'false' iff value is absent. Otherwise 'true'.
+repr()
returns "true" for true. "false" for false.
Returns a string representation of a value.
volatile
and(a : bool, b : bool)
returns true if both a and b are true, otherwise returns false.
Boolean AND

The compiler uses control flow to implement 'and' operation, therefore this function is only there for consistency.

uncertain
or(a : bool, b : bool)
returns true if either a or b is true, otherwise returns false.
Boolean OR

The compiler uses control flow to implement 'or' operation, therefore this function is only there for consistency.

uncertain
not(a : bool)
returns true if a is false.
Boolean not

The compiler uses control flow or instructions to implement 'not' operation, therefore this function is only there for consistency.

uncertain

02. Objects & Interfaces

Python calls 'interfaces' types and likewise has a 'type' where Lever has an interface.

The decision to use the name 'interface' here originates from the fact that you do not often touch these parts. Also the term 'type' is used usually to denote what kind of object you have stored into a json file.

Also we have a concept of a C type. The first-class C type system in Lever runtime is somewhat crucial element, and there will be more more of that as time goes on.

class object extends null
Base interface for everything
+init(obj = {})
returns A record object.
Instantiates a freeform record that can hold any attributes.

Oftentimes we have data that has to be structured, but it is also so short-lived that there's no point writing an explicit class definition for it.

There are plans to add list pattern matching into Lever some day, so some of these objects in the current runtime will be replaced with plain lists.

Despite that the concept will likely stay and you'll be able to instantiate by calling the object() interface.

This kind of "objects" can be converted back into dictionary with dict().

debatable
class interface extends interface
Interface for interfaces

Every value has an interface. Since interfaces are first class values they also have to have an interface.

+init(object)
returns interface of the object
Obtains the interface of an object given as an argument.

If you pass an interface, you get an interface back.

internals may change
isinstance(value : object, which : object)
value The value to test
which Interface or a list of interfaces
returns true if the object is an instance of certain interface.
Tests whether the object is an instance of an interface or a subinterface.
super(interface : interface)
returns interface
Returns a 'super interface' of the given interface.

This is a mostly feature for introspection. You can use it to obtain a parent interface of an interface until you hit the object, super(object) is null.

03. Functions & Multimethods

class builtin extends object
Type for builtin functions.
volatile

Every function, builtin or not has .spec and .loc attributes for introspection. They are both freely formed objects with attributes.

The shape and structure of all of these fields is very likely going to change, but for now we got something like this:

The introspection features will eventually improve until we can run abstract interpretation on the user-defined functions.

class multimethod extends object
Establishes a dispatch table that can be used to customize this method.

Multimethods represent bundles of functions of fixed arity. Programmer can insert more of functions into a multimethod at any time.

During invocation multimethods calls interface() for every argument they get. The result is used to determine the function to call. If the value is missing in the table, the default -method is called. If there's no default method, then an error is raised.

It is expected that multimethods have a clear semantic and modes of failures that are obeyed by the functions put into the table.

+init(arity)
returns a new multimethod that dispatches on the arity count of arguments.
A multimethod is partially mutable, but you are not expected to overwrite functions in a method table.
volatile
+setitem(self, key, function)
Adds a method into the dispatch table. The key must be a list containing interfaces, having a length matching the arity.

Fails if the key is already in the table.

volatile
+getitem(self, key)
returns The function associated to a key.
volatile
+call(args...)
Gathers the key from the arguments and attempts to call a function in the dispatch table. If the key isn't in the table, it will then call the .default(args...) to provide a default resolution.
volatile
call_suppressed(args...)
Dispatches on the multimethod table but returns an error instead of calling the .default(args...) if the dispatch fails.
volatile
keys()
returns The list of keys in the dispatch table.
Dispatches on the multimethod
volatile

Multimethods have an .arity field that tells their arity and a .default field that can be set. The .default field should be set only once.

volatile

04. Custom classes & objects

The class definitions are part of a language, but it can be interesting to know how they construct underneath.

class(freeform, super = object, name = "customobject")
freeform Freeform object holding the new fields for the new interface
super The interface that this interface extends from
returns a new interface
Called by the 'class' syntax.

Interfaces are immutable to favor the JIT compiler. This can be changed, but so far I haven't found a real need to change an interface after it has been created. It's usually just as simple to create a new interface.

volatile
class property extends object
Provides getters/setters via the class interface.
volatile
+init()
returns a new property object.
The getters and setters are put into .get and .set attributes of this object.
volatile

05. Primitives

class dict extends object
not documented
volatile
+contains()
returns not documented
not documented
volatile
+getitem()
returns not documented
not documented
volatile
+init(other = null)
other not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
+setitem()
returns not documented
not documented
volatile
get(argv...)
argv not documented
returns not documented
not documented
volatile
items(self : dict)
self not documented
returns not documented
not documented
volatile
keys(self : dict)
self not documented
returns not documented
not documented
volatile
pop(self : dict, key : object)
self not documented
key not documented
returns not documented
not documented
volatile
update(self : dict, other : object)
self not documented
other not documented
returns not documented
not documented
volatile
values(self : dict)
self not documented
returns not documented
not documented
volatile
class float extends object
not documented
volatile
+hash()
returns not documented
not documented
volatile
+init(obj : object)
obj not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
to_string(self : float)
self not documented
returns not documented
not documented
volatile
class int extends object
not documented
volatile
+hash()
returns not documented
not documented
volatile
+init(obj : object)
obj not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
to_string(integer : int, base = null)
integer not documented
base not documented
returns not documented
not documented
volatile
class list extends object
not documented
volatile
+contains()
returns not documented
not documented
volatile
+getitem()
returns not documented
not documented
volatile
+hash()
returns not documented
not documented
volatile
+init(argv...)
argv not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
+setitem()
returns not documented
not documented
volatile
append(self : list, other : object)
self not documented
other not documented
returns not documented
not documented
volatile
count(self : list, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
extend(self : list, iterable : object)
self not documented
iterable not documented
returns not documented
not documented
volatile
index(self : list, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
insert(self : list, index : int, obj : object)
self not documented
index not documented
obj not documented
returns not documented
not documented
volatile
pop(self : list, index = null)
self not documented
index not documented
returns not documented
not documented
volatile
remove(self : list, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
reverse(self : list)
self not documented
returns not documented
not documented
volatile
sort(self : list, lt = null)
self not documented
lt not documented
returns not documented
not documented
volatile
class set extends object
not documented
volatile
+contains()
returns not documented
not documented
volatile
+init(arg = null)
arg not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
add(self : set, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
clear(self : set)
self not documented
returns not documented
not documented
volatile
copy(self : set)
self not documented
returns not documented
not documented
volatile
difference(self : set, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
difference_update(self : set, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
discard(self : set, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
intersection(self : set, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
intersection_update(self : set, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
is_disjoint(self : set, arg : object)
self not documented
arg not documented
returns not documented
not documented
volatile
is_subset(self : set, other : object)
self not documented
other not documented
returns not documented
not documented
volatile
is_superset(self : set, arg : object)
self not documented
arg not documented
returns not documented
not documented
volatile
pop(self : set)
self not documented
returns not documented
not documented
volatile
remove(self : set, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
symmetric_difference(self : set, arg : object)
self not documented
arg not documented
returns not documented
not documented
volatile
symmetric_difference_update(self : set, arg : object)
self not documented
arg not documented
returns not documented
not documented
volatile
union(self : set, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
update(self : set, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
class slice extends object
not documented
volatile
+init(start : object, stop : object, step = null)
start not documented
stop not documented
step not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
class str extends object
not documented
volatile
+contains()
returns not documented
not documented
volatile
+getitem()
returns not documented
not documented
volatile
+hash()
returns not documented
not documented
volatile
+init(obj : object)
obj not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
center(self : str, width : int, fillchar = null)
self not documented
width not documented
fillchar not documented
returns not documented
not documented
volatile
count(self : str, ch : str)
self not documented
ch not documented
returns not documented
not documented
volatile
endswith(self : str, postfix : str)
self not documented
postfix not documented
returns not documented
not documented
volatile
is_alpha(string : str)
string not documented
returns not documented
not documented
volatile
is_digit(string : str, base = null)
string not documented
base not documented
returns not documented
not documented
volatile
is_space(string : str)
string not documented
returns not documented
not documented
volatile
join(string : str, seq : object)
string not documented
seq not documented
returns not documented
not documented
volatile
ljust(self : str, width : int, fillchar = null)
self not documented
width not documented
fillchar not documented
returns not documented
not documented
volatile
lower(obj : str)
obj not documented
returns not documented
not documented
volatile
replace(a : str, b : str, c : str)
a not documented
b not documented
c not documented
returns not documented
not documented
volatile
rjust(self : str, width : int, fillchar = null)
self not documented
width not documented
fillchar not documented
returns not documented
not documented
volatile
rsplit(self : str, sep : str, maxsplit = null)
self not documented
sep not documented
maxsplit not documented
returns not documented
not documented
volatile
split(self : str, sep : str, maxsplit = null)
self not documented
sep not documented
maxsplit not documented
returns not documented
not documented
volatile
startswith(self : str, prefix : str)
self not documented
prefix not documented
returns not documented
not documented
volatile
upper(obj : str)
obj not documented
returns not documented
not documented
volatile

06. String decoding & encoding & conversions

decode_utf8(value : Uint8Data)
value not documented
returns not documented
not documented
volatile
encode_utf8(value : str)
value not documented
returns not documented
not documented
volatile
class Utf8Decoder extends object
not documented
volatile
+call(argv...)
argv not documented
returns not documented
not documented
volatile
+init()
returns not documented
not documented
volatile
finish(self : Utf8Decoder)
self not documented
returns not documented
not documented
volatile
chr(value : int)
value not documented
returns not documented
Returns a character that corresponds to the integer.
volatile
ord(string : str)
string not documented
returns not documented
Returns integer representing the unicode point of the character.
volatile
parse_float(string : str)
string not documented
returns not documented
not documented
volatile
parse_int(string : str, base = null)
string not documented
base not documented
returns not documented
not documented
volatile

07. Path handling

class path extends object
Represents file paths. Note that irrespective of the OS, lever expects you to provide POSIX compatible paths.

Paths have mutable attributes "is_absolute", "basename", "label". There is also .push(path) -method to help in-place modify the path.

To pass path to FFI, the path object has "get_os_path" -method to convert the path into system path.

volatile
+hash()
returns not documented
not documented
volatile
+init(obj : object)
obj not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
drop(self : path, count : int)
self not documented
count not documented
returns not documented
not documented
volatile
get_os_path(self : path)
self not documented
returns not documented
not documented
volatile
relpath(dst : path, rel = null, cwd = null)
dst not documented
rel not documented
cwd not documented
returns not documented
not documented
volatile
to_string(self : path)
self not documented
returns not documented
not documented
volatile

08. Byte arrays

class Uint8Array extends Uint8Data
not documented
volatile
+init(obj : object)
obj not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class Uint8Builder extends object
not documented
volatile
+init()
returns not documented
not documented
volatile
append(self : Uint8Builder, obj : Uint8Data)
self not documented
obj not documented
returns not documented
not documented
volatile
build(self : Uint8Builder)
self not documented
returns not documented
not documented
volatile
class Uint8Data extends object
not documented
volatile
class Uint8Slice extends Uint8Data
not documented
volatile
+getitem()
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
+setitem()
returns not documented
not documented
volatile
memcpy(self : Uint8Data, src : Uint8Data, size = null)
self not documented
src not documented
size not documented
returns not documented
not documented
volatile

09. Basic I/O

stderr : TTY
not documented
volatile
stdin : TTY
not documented
volatile
stdout : TTY
not documented
volatile
print(argv...)
argv not documented
returns not documented
Prints the given values, with space between them.
volatile
class Pipe extends Stream
not documented
volatile
+init(ipc : bool)
ipc not documented
returns not documented
not documented
volatile
bind(self : Pipe, name : str)
self not documented
name not documented
returns not documented
not documented
volatile
connect(self : Pipe, name : str)
self not documented
name not documented
returns not documented
not documented
volatile
pending_count(self : Pipe)
self not documented
returns not documented
not documented
volatile
pending_instances(self : Pipe, count : int)
self not documented
count not documented
returns not documented
not documented
volatile
class Queue extends object
not documented
volatile
+init()
returns not documented
not documented
volatile
append(self : Queue, obj : object)
self not documented
obj not documented
returns not documented
not documented
volatile
close(self : Queue)
self not documented
returns not documented
not documented
volatile
wait(self : Queue)
self not documented
returns not documented
not documented
volatile
class Stream extends Handle
not documented
volatile
class StringBuilder extends object
not documented
volatile
+init()
returns not documented
not documented
volatile
append(self : StringBuilder, obj : str)
self not documented
obj not documented
returns not documented
not documented
volatile
build(self : StringBuilder)
self not documented
returns not documented
not documented
volatile
class TTY extends Stream
not documented
volatile
get_winsize(self : TTY)
self not documented
returns not documented
not documented
volatile
set_mode(self : TTY, modename_obj : str)
self not documented
modename_obj not documented
returns not documented
not documented
volatile
class Timer extends handle2
not documented
volatile
+init()
returns not documented
not documented
volatile
again(self : Timer)
self not documented
returns not documented
not documented
volatile
close(self : Timer)
self not documented
returns not documented
not documented
volatile
get_recv_buffer_size(self : handle2)
self not documented
returns not documented
not documented
volatile
get_send_buffer_size(self : handle2)
self not documented
returns not documented
not documented
volatile
set_repeat(self : Timer, value : float)
self not documented
value not documented
returns not documented
not documented
volatile
start(self : Timer, delay : float, repeat = null)
self not documented
delay not documented
repeat not documented
returns not documented
not documented
volatile
stop(self : Timer)
self not documented
returns not documented
not documented
volatile

10. Greenlets & Concurrency

sleep(argv...)
argv not documented
returns not documented
The sleep performs two functions. It can be used to suspend the current greenlet, queue it after duration of seconds pass.

If you pass it a function or greenlet, it will convert it into a greenlet and adds it to the event queue after the duration passes.

volatile
schedule(argv...)
argv not documented
returns newly created greenlet
Schedule is similar to the greenlet -command, except that it queues the greenlet and sets it to return into the eventloop when it finishes. It returns the newly created greenlet.
volatile
getcurrent()
returns The currently running greenlet.
not documented
volatile
class greenlet extends object
A stack branch point, or something like that

Conceptually greenlets represent a body of work you can stop for a moment while you do a different task. Note that you are always in a greenlet. You can always put the current task to sleep, or switch to the eventloop to run a different task.

Greenlet represents a call frame that can be suspended. The arguments describe a function to call and it can be left blank. In that case the switching has to pass a function that is called inside the greenlet.

The greenlet.parent describes where the call returns once it finishes.

greenlet.switch(arguments...) suspends the current greenlet and switches to the targeted greenlet. If the greenlet hasn't started yet, the given arguments are concatenated to the initial arguments. If the greenlet is suspended, the arguments are compacted into a value and returned in the target greenlet.

volatile
+init(argv...)
argv not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
switch(argv...)
argv not documented
returns not documented
not documented
volatile

11. Runtime

getattr(obj : object, index : str)
obj not documented
index not documented
returns not documented
Retrieves attribute from an object.
volatile
getitem(obj : object, index : object)
obj not documented
index not documented
returns not documented
Equivalent to object[index]. Presented as a convenience. Invokes the +getitem from the interface table.
volatile
hash(obj : object)
obj not documented
returns not documented
not documented
volatile
iter(obj : object)
obj not documented
returns not documented
Retrieve an iterator. Invokes the +iter from the interface table.
volatile
len(obj : object)
obj not documented
returns not documented
not documented
volatile
listattr(obj : object)
obj not documented
returns not documented
not documented
volatile
load(program : object, path = null)
program not documented
path not documented
returns not documented
not documented
volatile
range(start : int, stop = null, step = null)
start not documented
stop not documented
step not documented
returns not documented
not documented
volatile
repr(obj : object)
obj not documented
returns not documented
not documented
volatile
reversed(obj : list)
obj not documented
returns not documented
not documented
volatile
setattr(obj : object, index : str, value : object)
obj not documented
index not documented
value not documented
returns not documented
Sets an attribute to an object.
volatile
setitem(obj : object, index : object, value : object)
obj not documented
index not documented
value not documented
returns not documented
Equivalent to object[index] = value. Presented as a convenience. Invokes the +setitem from the interface table.
volatile

12. Modules

Modules are hierarchical now, but I'm wondering whether the hierarchical idea of modules should be moved into the evaluation environment or program objects instead.

There is a function "import" that imports a module and is used behind the import syntax. Every module has an import function and it is always an instance of a Import.

class Module extends object
not documented
volatile
class Import extends object
not documented
volatile
+call(argv...)
argv not documented
returns not documented
not documented
volatile
+init(local : path, scope : ModuleScope)
local not documented
scope not documented
returns not documented
not documented
volatile
class ModuleScope extends object
not documented
volatile
+getitem()
returns not documented
not documented
volatile
+init(local : path, parent = null, options = null)
local not documented
parent not documented
options not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
reimport(scope : ModuleScope, obj : str)
scope not documented
obj not documented
returns not documented
not documented
volatile

13. Logging

info(value : object, type = null)
value not documented
type not documented
returns not documented
not documented
volatile
new_log()
returns not documented
not documented
volatile

14. Errors and exceptions

format_traceback(exception : object)
exception not documented
returns not documented
not documented
volatile
class ValueError extends Exception
not documented
volatile
+init(obj : object, value : object)
obj not documented
value not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class UncatchedStopIteration extends Exception
not documented
volatile
+repr()
returns not documented
not documented
volatile
class TypeError extends Exception
not documented
volatile
+init(message : str)
message not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class UNKNOWN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class UVError extends Exception
not documented
volatile
+repr()
returns not documented
not documented
volatile
class SystemExit extends Exception
not documented
volatile
+repr()
returns not documented
not documented
volatile
class InstructionError extends Exception
not documented
volatile
+repr()
returns not documented
not documented
volatile
class KeyError extends Exception
not documented
volatile
+init(obj : object, name : str)
obj not documented
name not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class Error extends Exception
not documented
volatile
+init(message : str)
message not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class Event extends object
not documented
volatile
+init()
returns not documented
not documented
volatile
close(self : Event)
self not documented
returns not documented
not documented
volatile
dispatch(self : Event, argv...)
self not documented
argv not documented
returns not documented
not documented
volatile
register(self : Event, cb : object)
self not documented
cb not documented
returns not documented
not documented
volatile
unregister(self : Event, cb : object)
self not documented
cb not documented
returns not documented
not documented
volatile
wait(self : Event)
self not documented
returns not documented
not documented
volatile
class Exception extends object
not documented
volatile
class FrozenError extends Exception
not documented
volatile
+init(obj : object)
obj not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class Handle extends object
not documented
volatile
class IOError extends Exception
not documented
volatile
+repr()
returns not documented
not documented
volatile
class AssertionError extends Exception
not documented
volatile
+init(thing : object)
thing not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class AttributeError extends Exception
not documented
volatile
+init(obj : object, name : str)
obj not documented
name not documented
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile
class CallError extends Exception
not documented
volatile
+repr()
returns not documented
not documented
volatile
class E2BIG extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EACCES extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EADDRINUSE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EADDRNOTAVAIL extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAFNOSUPPORT extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAGAIN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_ADDRFAMILY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_AGAIN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_BADFLAGS extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_BADHINTS extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_CANCELED extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_FAIL extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_FAMILY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_MEMORY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_NODATA extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_NONAME extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_OVERFLOW extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_PROTOCOL extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_SERVICE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EAI_SOCKTYPE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EALREADY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EBADF extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EBUSY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ECANCELED extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ECHARSET extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ECONNABORTED extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ECONNREFUSED extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ECONNRESET extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EDESTADDRREQ extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EEXIST extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EFAULT extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EFBIG extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EHOSTDOWN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EHOSTUNREACH extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EINTR extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EINVAL extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EIO extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EISCONN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EISDIR extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ELOOP extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EMFILE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EMSGSIZE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENAMETOOLONG extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENETDOWN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENETUNREACH extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENFILE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOBUFS extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENODEV extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOENT extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOMEM extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENONET extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOPROTOOPT extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOSPC extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOSYS extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOTCONN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOTDIR extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOTEMPTY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOTSOCK extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENOTSUP extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ENXIO extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EOF extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EPERM extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EPIPE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EPROTO extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EPROTONOSUPPORT extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EPROTOTYPE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ERANGE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EROFS extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ESHUTDOWN extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ESPIPE extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ESRCH extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ETIMEDOUT extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class ETXTBSY extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile
class EXDEV extends UVError
not documented
volatile
+repr()
returns not documented
not documented
volatile

15. Operators

Nearly all operators in Lever are multimethods. The current Lever multimethods can be extended but they do not obey type inheritance.

coerce
Arithmetic coercion.

A Base multimethod for converting two value into values that pair arithmetically. Coercion is used when the values cannot be found from the usual multimethod table and when the exact pairing cannot be found.

Sometimes we expect that two types are arithmetically interchangeable although they would be technically different. Therefore many arithmetic operations in Lever come with coercion as default for the time when there's not a specific method for the given operation.

This method must coerce the two values into most specific common type they share.

The conversion must make sense before doing an arithmetic operation such as addition, multiplication or substraction.

(a : float, b : int)
returns float
Implicit conversion to float from integers.
volatile
(a : int, b : float)
returns float
Implicit conversion to float from integers.
volatile
(a : bool, b : int)
returns int
Implicit conversion from boolean into integer.

'true' becomes 1, and 'false' becomes 0.

volatile
(a : bool, b : bool)
returns int
Implicit conversion from booleans into integers.

This is not the most common type for booleans, but usually when we are doing arithmetic operation and there are no booleans defined, we expect that they represent integer values.

volatile
(a : int, b : bool)
returns int
Implicit conversion from boolean into integer.
volatile
volatile
+
Arithmetic addition
(a : vec3, b : vec3)
returns vec3
Addition is defined on vectors.
volatile
(a : int, b : int)
returns int
volatile
(a : float, b : float)
returns float
volatile
default(args...)
Calls coerce on the arguments and re-attempts the operation on the results once.
volatile
volatile
-
Arithmetic subtraction
(a : vec3, b : vec3)
returns vec3
Of course...
volatile
(a : set, b : set)
returns set
Alias to set.difference
volatile
(a : int, b : int)
returns int
What do you expect?
volatile
(a : float, b : float)
returns float
Kind of obvious.
volatile
default(args...)
Calls coerce on the arguments and re-attempts the operation on the results once.
volatile
volatile
*
Multiplication of two elements together
(n : int, s : str)
returns str
Repeats the 's' string 'n' times.

Multiplication in this case makes a lot of sense, although repeating of a string is a repeat of concatenation rather than addition.

volatile
(a : mat4, b : mat4)
returns mat4
Matrix multiplication.
volatile
(a : int, b : int)
returns int
volatile
(s : str, n : int)
returns str
Repeats the 's' string 'n' times.
volatile
(a : float, b : float)
returns float
volatile
(s : float, v : vec3)
returns vec3
Vector multiplication by scalar
volatile
(q : quat, v : vec3)
returns vec3
I am a bit unsure about what this was.. TODO: review quaternion math.
volatile
(self : mat4, other : vec3)
returns vec3
Plain old matrix multiplication of vector.

Transforms the vector by the matrix.

volatile
(v : vec3, s : float)
returns vec3
Scalar multiplication on vector.
volatile
(self : quat, other : quat)
returns quat
Quaternion multiplication
volatile
default(args...)
Calls coerce on the arguments and re-attempts the operation on the results once.
volatile
volatile
/
Arithmetic division operator
(self : vec3, s : float)
self not documented
s not documented
returns not documented
not documented
volatile
(s : float, self : vec3)
s not documented
self not documented
returns not documented
not documented
volatile
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
default(argv...)
argv not documented
returns not documented
not documented
volatile
volatile
+expr
Prefix plus
(self : quat)
self not documented
returns not documented
not documented
volatile
(a : int)
a not documented
returns not documented
not documented
volatile
(self : vec3)
self not documented
returns not documented
not documented
volatile
(a : float)
a not documented
returns not documented
not documented
volatile
volatile
%
Modulo takes a remainder from the division of the first argument by the second.
(a : int, b : int)
returns int
volatile
default(args...)
Default on module is an arithmetic coercion and a re-attempt once.
volatile
volatile
&
Bitwise AND
(a : int, b : int)
returns int
volatile
(a : set, b : set)
returns set
Alias to set.intersection
volatile
default(args...)
Default on module is an arithmetic coercion and a re-attempt once.
volatile
volatile
|
Bitwise OR operation or similar
(a : int, b : int)
returns int
Bitwise OR operation on two integers
volatile
(a : set, b : set)
returns set
An alias to set.union

This behavior has been inherited from Python.

volatile
default(args...)
Calls coerce on the arguments and re-attempts the operation on the results once.
volatile
volatile
^
Bitwise XOR operator
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : set, b : set)
a not documented
b not documented
returns not documented
not documented
volatile
default(argv...)
argv not documented
returns not documented
not documented
volatile
volatile
==
Equality
(a : path, b : path)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
(a : list, b : list)
a not documented
b not documented
returns not documented
not documented
volatile
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : str, b : str)
a not documented
b not documented
returns not documented
not documented
volatile
(a : Id, b : Id)
a not documented
b not documented
returns not documented
not documented
volatile
(a : EIM, b : EIM)
a not documented
b not documented
returns not documented
not documented
volatile
default(a : object, b : object)
a not documented
b not documented
returns not documented
not documented
volatile
volatile
!=
Inequality operator
(a : path, b : path)
returns bool
Two path objects are inequal if their prefixes and path sequences are different.
volatile
(a : str, b : str)
returns bool
Two strings are inequal if they are different.
volatile
(a : int, b : int)
returns bool
Two integers are inequal if erm...
volatile
(a : float, b : float)
returns bool
volatile
default(a : object, b : object)
returns bool
By default, two items are inequal if they are not equal as defined by ==.
volatile
volatile
++
Concatenation

Concatenation and addition are not a same thing because the two can make sense separately in a same object. This was the case in the numpy module of the Python. We rather do not repeat that mistake.

(a : Uint8Array, b : Uint8Array)
returns Uint8Array
Concatenates two byte arrays together.

This operation always allocates new memory to contain the new concatenated byte sequence.

volatile
(a : path, b : path)
returns path
Concatenates two paths together.

If the 'b' path is not a relative path, it is returned. Otherwise we get a concatenation of the two.

volatile
(a : Uint8Array, b : Uint8Slice)
returns Uint8Array
Concatenates two byte arrays together.

This operation always allocates new memory to contain the new concatenated byte sequence.

volatile
(a : Uint8Slice, b : Uint8Array)
returns Uint8Array
Concatenates two byte arrays together.

This operation always allocates new memory to contain the new concatenated byte sequence.

volatile
(a : path, s : str)
returns path
Converts a string into a path and then proceeds to concatenate the two.

String concatenation from the right side is extremely common operation, for example 'a.dirname ++ (a.basename ++ ".text")' adds a file extension '.text'

volatile
(a : list, b : list)
returns list
List concatenation
volatile
(a : str, b : path)
returns path
Converts a string into a path and then proceeds to concatenate the two.

Not as common as the another, but is present there for convenience.

volatile
(a : str, b : str)
returns str
String concatenation.
volatile
(a : Uint8Slice, b : Uint8Slice)
returns Uint8Array
Concatenates two byte arrays together.

This operation always allocates new memory to contain the new concatenated byte sequence.

volatile
volatile
-expr
(self : quat)
self not documented
returns not documented
not documented
volatile
(a : int)
a not documented
returns not documented
not documented
volatile
(self : vec3)
self not documented
returns not documented
not documented
volatile
(a : float)
a not documented
returns not documented
not documented
volatile
volatile
<
Less than -operator
(a : path, b : path)
a not documented
b not documented
returns not documented
not documented
volatile
(a : str, b : str)
a not documented
b not documented
returns not documented
not documented
volatile
(a : set, b : set)
a not documented
b not documented
returns not documented
not documented
volatile
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
volatile
<=
Less than or equal -operator
(a : path, b : path)
a not documented
b not documented
returns not documented
not documented
volatile
(a : str, b : str)
a not documented
b not documented
returns not documented
not documented
volatile
(a : set, b : set)
a not documented
b not documented
returns not documented
not documented
volatile
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
volatile
>
Greather than -operator
(a : path, b : path)
a not documented
b not documented
returns not documented
not documented
volatile
(a : str, b : str)
a not documented
b not documented
returns not documented
not documented
volatile
(a : set, b : set)
a not documented
b not documented
returns not documented
not documented
volatile
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
volatile
>=
Greater than or equal -operator
(a : path, b : path)
a not documented
b not documented
returns not documented
not documented
volatile
(a : str, b : str)
a not documented
b not documented
returns not documented
not documented
volatile
(a : set, b : set)
a not documented
b not documented
returns not documented
not documented
volatile
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
volatile
<<
Left bitwise shift
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
default(argv...)
argv not documented
returns not documented
not documented
volatile
volatile
>>
Bitwise right shift
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
default(argv...)
argv not documented
returns not documented
not documented
volatile
volatile

16. Mathematic functions and interfaces

abs(f : float)
f not documented
returns not documented
not documented
volatile
axisangle(v : vec3, angle : float)
v not documented
angle not documented
returns not documented
not documented
volatile
backward : vec3
not documented
volatile
clamp
(x : float, low : float, high : float)
x not documented
low not documented
high not documented
returns not documented
not documented
volatile
(x : int, low : int, high : int)
x not documented
low not documented
high not documented
returns not documented
not documented
volatile
(c : slice, start : int, stop : int)
c not documented
start not documented
stop not documented
returns not documented
not documented
volatile
not documented
volatile
cos(f : float)
f not documented
returns not documented
not documented
volatile
cross
(a : vec3, b : vec3)
a not documented
b not documented
returns not documented
not documented
volatile
not documented
volatile
dot
(a : vec3, b : vec3)
a not documented
b not documented
returns not documented
not documented
volatile
not documented
volatile
down : vec3
not documented
volatile
e = 2.71828182846
not documented
volatile
exp(a : float)
a not documented
returns not documented
not documented
volatile
left : vec3
not documented
volatile
length
(v : vec3)
v not documented
returns not documented
not documented
volatile
not documented
volatile
ln(a : float)
a not documented
returns not documented
not documented
volatile
log(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
class mat4 extends object
not documented
volatile
+init(argv...)
argv not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
adjoint(self : mat4)
self not documented
returns not documented
not documented
volatile
determinant(self : mat4)
self not documented
returns not documented
not documented
volatile
invert(self : mat4)
self not documented
returns not documented
not documented
volatile
rotate_vec3(self : mat4, v : vec3)
self not documented
v not documented
returns not documented
not documented
volatile
scale(self : mat4, v : vec3)
self not documented
v not documented
returns not documented
not documented
volatile
translate(self : mat4, v : vec3)
self not documented
v not documented
returns not documented
not documented
volatile
transpose(self : mat4)
self not documented
returns not documented
not documented
volatile
max
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
default(argv...)
argv not documented
returns not documented
not documented
volatile
not documented
volatile
min
(a : int, b : int)
a not documented
b not documented
returns not documented
not documented
volatile
(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
default(argv...)
argv not documented
returns not documented
not documented
volatile
not documented
volatile
forward : vec3
not documented
volatile
normalize
(v : vec3)
v not documented
returns not documented
not documented
volatile
not documented
volatile
pi = 3.14159265359
Half of the circumference of an unit circle.
volatile
tau = 6.28318530718
Circumference of an unit circle.
volatile
pow(a : float, b : float)
a not documented
b not documented
returns not documented
not documented
volatile
projection_matrix(fovy : object, aspect : object, znear : object, zfar : object)
fovy not documented
aspect not documented
znear not documented
zfar not documented
returns not documented
not documented
volatile
class quat extends object
not documented
volatile
+init(argv...)
argv not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
invert(self : quat)
self not documented
returns not documented
not documented
volatile
to_mat4(self, translation = vec3(0,0,0))
returns Affine transformation matrix.
Present your affection to your significant other with matrices.
volatile
runtime_path : path
not documented
volatile
sign(f : float)
f not documented
returns not documented
not documented
volatile
sin(f : float)
f not documented
returns not documented
not documented
volatile
sqrt(f : float)
f not documented
returns not documented
not documented
volatile
tan(f : float)
f not documented
returns not documented
not documented
volatile
up : vec3
not documented
volatile
class vec3 extends object
not documented
volatile
+init(argv...)
argv not documented
returns not documented
not documented
volatile
+iter()
returns not documented
not documented
volatile
+repr()
returns not documented
not documented
volatile

17. Random numbers and quantities

random()
returns not documented
not documented
volatile
random_circle()
returns Random unit vector on a plane.
This was copied from somewhere in the internet.
volatile
random_sphere()
returns Random unit vector.
This was copied from somewhere in the internet.
volatile

18. Miscellaneous

chdir(obj : object)
obj not documented
returns not documented
Changes the current directory.

Note that both getcwd() and chdir(path) may eventually move into fs -module.

volatile
class DocRef extends object
not documented
volatile
+init(doc : object, name : object, parent = null)
doc not documented
name not documented
parent not documented
returns not documented
not documented
volatile
exit(obj = null)
obj not documented
returns not documented
not documented
volatile
class Id extends object
not documented
volatile
+getitem()
returns not documented
not documented
volatile
+hash()
returns not documented
not documented
volatile
+init(ref : object)
ref not documented
returns not documented
not documented
volatile
+setitem()
returns not documented
not documented
volatile
get(self : Id, name : str, default = null)
self not documented
name not documented
default not documented
returns not documented
not documented
volatile
getcwd()
returns not documented
Returns a path object denoting the current path. Note that this object is converted once, so if you have unusual path that doesn't follow posix conventions, the lever getcwd may give a incorrect path.

Note that both getcwd() and chdir(path) may eventually move into fs -module.

volatile
time(argv...)
argv not documented
returns not documented
not documented
volatile