- A declared class is used to store properties, rules, and definitions for instances of that class.
- DeclareClass it typically evaluated in a context reserved specifically for class definitions.
- ClassQ[class] returns True for a symbol class that has been successfully declared a class using DeclareClass.
- DeclareClass[class] and DeclareClass[class,parent] only work if class is not yet a declared class, and if it does not have the attribute Protected. parent has to be a declared class.
- Instances of class class are internally stored as class[assoc], with assoc an Association object.
- Default values for class elements can be added with DeclareDefaults[class,defaults], but only after class has been declared using DeclareClass.
- Invariants for class can be added with DeclareInvariant[class,invariant], but only after class has been declared using DeclareClass.
- The class property property for a declared class class can be requested using class[property].
- DeclareClass sets up the following basic class properties for the symbol class:
the base class "
the class symbol "
the defaults specified for the class "
- the invariant specified for the class
the defaults specified for the class and its parents "
the format rules for the class "
a default instance "
the invariant specified for the class and its parents "
the parent symbol "
the defaults specified for the class parents "
the invariant specified for the class parents "
list of all class parents "
list of all properties
- Once a symbol class is a declared class, class instances can be created by evaluating class[elements], with elements a rule, list of rules, or Association object.
- Part can be used to retrieve values in a class instance as a shorthand for Retrieve, and, in combination with ClassSet or ClassSetDelayed, modify values in a class instance.
- Normal[instance] returns an Association object with the elements stored in the class instance instance.
- The instance property property can be requested from an instance instance using instance[property].
- Instance and class properties can be defined and redefined using Set and SetDelayed.
- Formatting rules, default values, instance properties, and class properties are all forwarded to a child class' parent, unless they have been redefined.
- Class symbols by default have the attribute ReadProtected.
- Class symbols can be protected from unintended changes with the usual Protected, ReadProtected, and Locked attributes.