Infrastructure for Primitive Definition
The MLDesigner kernel provides a number of C++ classes that often prove useful to primitive writers. Some of these are essential such as those that handle errors. Complete documentation of the kernel classes is given in a separate section. Here, we summarize only the most generic of these classes, i.e., the ones that are generally useful to primitive programmers. All of these classes described here may be used in primitives, provided that the primitive writer includes the appropriate header files.
For instance, the entry
ccinclude { "kernel/pt_fstream.h" }
will permit the primitive to create instances of the basic stream classes (described below) in the body of functions that are defined in the primitive.
If the programmer wishes to create an instance as a private, protected or public member of the primitive, then the header file needs to be included in the .h file, specified in the line
hinclude { "kernel/pt_fstream.h" }
in the SDF primitive Printer defined here.
Handling Errors
Uniform handling of errors is provided by the Error class.
I/O Classes
The programmer who is working with primitives often needs to communicate with the user. There are several classes to accomplish that.
String Functions and Classes
The MLDesigner kernel defines some ordinary functions (not classes) plus two classes that are useful for building and manipulating C style strings.
List Classes
The StringList class is derived from the SequentialList class. This class is widely used within MLDesigner to provide list functionality. It implements a linked list with a running count of the number of elements.
Hash Tables
Hash tables are lists that are indexed by an ASCII string.
Using Random Numbers
The primitives Random* found in the Number Generators library replaces the wide range of primitives that were previously available and have been moved to Compatibility→NumberGenerators. Every time the primitive is executed it generates a value that is a random deviate drawn from the distribution selected by parameter Distribution.