- Class symbols should not have user-defined values of any kind, because they are cleared during class generation.
- There should be no user symbols in a context that has the same name as a class, because they are removed during class generation.
- A method overrides another one only, if
Mathematica`s pattern matcher distiguishes both. For example,
f[]/;(Print[1];True) and
f[]/;(Print[2];True) are different patterns, while
f[x_] and
f[y_] represent the same pattern.
f[]/;condition is always different in different classes, if class members are accessed within condition, because the condition is automatically called with a local value of
$CalledClass that is different for different classes.
- Methods may not have SubValues.
- Methods may not have user-defined
UpValues.
- Class names may not have attribute
Locked before the class is defined.
- Symbols local to
Block hide class fields in
Dot (Class[A]:={v={3, 4}, m[]:=Block[{v={1, 2}}, v.v]}; New.A[].m[] yields
5).
- If
a is a class member of both classes
A and
B,
bb=New.B[] and
A has
b=bb,
b.a does not access the member a of
B but represents an inner product of
bb and the member a of
A (this interpretation rule allows easier usage of class members in inner products).
- Anologously,
Class[A]:={f[a_]:=1}; Class[B]:={v=New.A[], g[]:=v.f[v.v]}; New.B[].g[] must fail, because
v.v evaluates to
a.v and
A has no member
v.
- If a symbol exists in the current private context (not on path) and in a context on the context path, only the latter is accessible within a newly defined class.
- If a method name has the attribute
Locked, already assigned attributes are taken and specifications within the class are ignored.
- During the definition of a class the standard output is suppressed.
- If two adjacent patterms of a method both allow a variable length of arguments, the corresponding arguments are accessed twice (important for side effects in conditions) and the method call may be slower.
-
"JLink`" is loaded in order to handle the possible naming conflict of InstanceOf. If
"JLink`" /
"NETLink`" is reloaded after this package, the part of the usage message of
InstanceOf related to this package is lost. This does not apply to
Mathematica versions with the link functionality built into the kernel.
- Use
Needs["Class`Class`"] before
BeginPackage[..., "Class`Class`", ...] for
Mathematica versions that do not have the Java link built into the kernel in order to have all symbols in the right context.