This section may be skipped on first reading.
Some names used in the standard library differ from those found in the traditional languages like C. In particular, fixed-length indexed arrays are called ``vectors.'' The name ``array'' is used for variable-length indexed arrays which allow adding and removing elements from both ends and can expand or shrink at runtime depending on the number of elements they are holding. The indexing operation is denoted by ``!'' (which is an infix version of fetch), because the traditional bracket notation ``[]'' is used by the Diesel language to indicate parameterization of classes/types and functions. For example, printing out an array element (or, more generally, a table element) can be done like this: (a!i).print_line;.
Creation of new instances of classes at runtime is typically achieved
by new_
methods which encapsulate the new object creation
and initialization expressions. The name of such a method usually
starts with new_
followed by the name of the concrete class
whose instance is being created; sometimes a suffix is used to
distinguish between different versions. However, this is merely a
convention. Notable exceptions from this convention are methods that
construct cons cells, pairs, triples, quadruples, and quintuples, which don't start with new_
.
Here are some examples:
Many operations that may produce an error or a special condition (e.g., indexing an array) take an optional last argument which is the closure to be invoked in such case. Thus, a programmer may either ignore the possibility of an error (which would halt the program) or handle the error condition (e.g., return a certain object when the array index is out of bounds). The default value of the closure typically invokes the error method, which prints a message, offers a debugging prompt, and then terminates the program. For example: