Releases: faysou/MTools
Small improvement to code for stability
Major refactoring of the method resolution to be faster
After many years asking myself how I could avoid the rule that was responsible for method resolution (HoldPattern[class[params___].(f:Except[super])[args___] /; !TrueQ[$blockSub[class, f]] ] :> class[params].sub.f[args]), I managed to find another mechanism that can rely solely on the traditional mathematica evaluation using UpValues.
The key idea consists in storing method definitions using the form o_MyClass.this.f[x_] instead of o_MyClass.f[x_] (the rewriting is done automatically, existing code still works). This then avoids having to intercept method calls of the form o.f[] using the rule above that was required previously.
There was also a sub funtion responsible for executing a given definition (Class[object].sub.f[]) that is not used anymore, that's why I'm bumping the version by 1 in the first part of the version.
My estimate is that the new method resolution is at least two times faster than before.
Maintenance release for Mathematica v12
Changed SetField symbol to SetProp.
0.4.5
0.4.0
Added final functions. Final functions are functions that are not overloaded in sub classes. Defining one allows to gain some overhead time when calling an object function. This is useful for functions called a lot.
To define a final function two syntaxes exist. Note that a final function must also be exported from a package as the function dispatcher (sub or super) may be skipped.
FinalFunctionBlock[
MyClass.f[x_]:= x;
];
MyClass.f[x_]:= x;
SetFinalFunction[MyClass,f];
Most BaseClass functions are final functions as well as iterate and superIterate in GenericClass and GenericGroup.
0.3.4
0.3.2
0.3.1
0.3.0
Added syntax for not storing all optional arguments in an object by default. If an option name is surrounded by a list, it is not stored in the object at creation time. To access this argument, the BaseClass.getOption function can be used.
For exampe
xx = NewClass["Fields"->{"a", {"b"} ,{"c"}->2, { {"d"}->3,"PopupMenu","Specs"->{{1,2,3}} } }];
xx .init[options_]:= o.getOption[options,"b"] // Print;
x = New[xx]["b"->2]
x // Keys