Modules index

# Builtins

This module provides access to the builtin Converge types.

`class Class`:
The standard class `Class`.

`func conformed_by(o):` Succeeds if `o` contains correspondingly named slots as each field in this class and its superclasses. Note that `o` may also contain other slots beyond this.

`func instantiated(o):` Succeeds if this class (or one of its subclasses) instantiated `o`.

`func get_field(name):` Returns the field `name` in the class, raising an exception if it does not exist.

`func iter_defns():` Successively generates each (field name, field value) pair for the class (note that this does not include slots defined in superclasses).

`func set_field(name, val):` Sets the value of field `name` to `val`, creating `name` if it did not previously exist.

`func get_supers():` Returns a list of all this parents superclasses.

`class Dict`:
The standard class `Dict`.

`func del(o):` Deletes the entry `o`. If 'o' is not found an exception is raised.

`func extend(o):` Adds every element from the dictoinary `o` into the dictionary. Key conflicts are resolved in favour of `o` i.e. elements in `o` overwrite elements in the dictionary being extended.

`func find(o, default := fail):` Returns the value of `key`. If 'key' is not found, 'default' is returned or, if no default value is specified, it fails. Note that unlike many other fuctions named `find`, this only returns a single value.

`func get(o, default := fail):` Returns the value of `key`. If 'key' is not found, 'default' is returned or, if no default value is specified, an exception is raised.

`func iter():` Successively generates each `[key, val]` pair in this dictionary.

`func iter_keys():` Successively generates each key in this dictionary.

`func len():` Returns the number of keys in this dictionary.

`func set(key, val):` Sets the value of `key` to `val`. If `key` was previously associated with a value, `val` overwrites the previous association. Returns null.

`func iter_vals():` Successively generates each value in this dictionary.

`class Int`:
Implements all the standard `Number` functions with the following addition:

`func idiv(n):` Returns the integer value of dividing this integer by `n`.

`class List`:
The standard class `List`.

`func append(o):` Adds `o` to the end of the list.

`func del(i):` Deletes the element at position `i`, raising an exception if `i` is out of bounds.

`func extend(c):` Appends each element returned by `c.iter()`.

`func find(o):` Successively generates each element in the list which compares equal to `o`.

`func find_index(o):` Successively generates the index of each element in the list which compares equal to `o`.

`func flattened():` Returns a copy of this list with each sub-list recursively flattened. e.g. `flattened([1, 2, [3, [4, 5]], 6])` returns `[1, 2, 3, 4, 5, 6]`.

`func get(i):` Returns the element at position `i`, raising an exception if `i` is out of bounds.

`func get_slice(lower := 0, upper := self.len()):` Returns a sub-list of the elements from position `lower` (inclusive) to `upper` (exclusive). An exception is raised if either index is out of bounds.

`func insert(i, o):` Inserts `o` at position `i`, causing the original values of position `i` (inclusive) to `self.len()` (exclusive) to be shuffled up by one position. An exception is raised if `i` is out of bounds.

`func iter(lower := 0, upper := self.len()):` Successively generates, in order, each value in the list.

`func len():` Returns the number of entries in the list.

`func pop():` Deletes the last position in the list, returning that positions value.

`func remove(o):` Successively deletes, in order, each element which equals `o`. Returns the value of that entry on each successful deletion, failing when no elements remain to be deleted.

`func riter():` Successively generates, in reverse order, each value in the list.

`func set(i, val):` Sets the value at position `i` to `val`. Raises an exception if `i` is out of bounds.

`func set_slice(lower := 0, upper := self.len(), c):` Effectively deletes the elements from position `lower` (inclusive) to `upper` (exclusive) and then successively inserts each element returned by `c.iter()` at position `lower + position in c`. An exception is raised if either index is out of bounds.

`class Module`:
The standard class `Module`.

`func new(bc):` Creates a new module from the string `bc`, which should be the contents of a `.cvb` file.
Module objects have the following slots:

`func defn_names():` Successively generates each definition name in the module.

`func get_defn(name):` Returns the definition named `name` in this module.

`func set_defn(name, val):` Sets the value of the definition named `name` in this module to `val`.

`func iter_defns():` Successively generates each (definition name, definition value) pair for the module.

`class Number`:
The standard class `Number`.

`class Object`:
The standard class `Object`.

`func init():` The standard object initialisation function; effectively a no-op.

`func find_slot(name):` Returns the value of the slot `name`, or fails if no such slot exists.

`func get_slot(name):` Returns the value of the slot `name`, raising an exception if no such slot exists.

`func iter_slots():` Successively generates each (slot name, slot value) pair for the object.

`func set_slot(name, val):` Sets the value of slot `name` to `val`, creating `name` if it did not previously exist.

`class Set`:
The standard class `Set`. Note that Converge's sets are mutable.

`func add(o):` Adds `o` to the set, overwriting the previous object which compared equal to `o` if it existed.

`func complement(s):` Returns a new set which contains every element of `self` which is not in `o`.

`func del(o):` Removes the entry `o`. If 'o' is not found an exception is raised.

`func extend(c):` Successively adds each element returned by `c.iter()` to the set.

`func find(o, default := fail):` Returns the object which compares equal to `o`. If no such object is not found, 'default' is returned or, if no default value is specified, it fails. Note that unlike many other fuctions named `find`, this only returns a single value.

`func iter():` Successively generates each value in the set.

`func len():` Returns the number of entries in the set.

`class String`:
The standard class `String`. Note that Converge's strings are immutable, and the API is designed with this in mind.

`func find(s):` Successively generates each substring which matches `s` (in practice this means that 's' itself will be returned for each match, but is defined this way for consistency with other `find` functions).

`func find_index(s):` Successively generates, in order, the starting index of each substring which matches `s`.

`func get(i):` Returns the character at position `i`, raising an exception if `i` is out of bounds.

`func hash():` Returns this strings hash value.

`func get_slice(lower := 0, upper := self.len()):` Returns a sub-string of the characters from position `lower` (inclusive) to `upper` (exclusive). An exception is raised if either index is out of bounds.

`func iter(lower := 0, upper := self.len()):` Successively generates, in order, each character in the string.

`func len():` Returns the number of characters in the string.

`func lower_cased():` Returns a copy of this string with all characters converted to lower case.

`func lstripped():` Returns a copy of this string with all whitespace (tabs, spaces, newlines) removed from its left hand side.

`func prefixed_by(s, i := 0):` Succeeds if the string starting at position `i` matches `s` in its entirety.

`func rfind_index(s):` Successively generates, in reverse order, the starting index of each substring which matches `s`.

`func stripped():` Returns a copy of this string with all whitespace (tabs, spaces, newlines) removed from both its left and right hand side.

`func suffixed_by(s, i := self.len()):` Succeeds if the string ending at position `i` matches `s` in its entirety.

`func replaced(old, new):` Returns a new string with each substring matching `old` replaced with `new`.

`func upper_cased():` Returns a copy of this string with all characters converted to upper case.

cvd_to_html ©2006-2007 Laurence Tratt