Skip to content

Releases: faysou/MTools

Small improvement to code for stability

Choose a tag to compare

@faysou faysou released this 27 Feb 10:31

Improved code so ResetClasses works correctly (cached function rules are all matched and removed when resetting classes).

Major refactoring of the method resolution to be faster

Choose a tag to compare

@faysou faysou released this 14 Feb 15:56

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

Choose a tag to compare

@faysou faysou released this 20 May 06:56

Changed SetField symbol to SetProp.

0.4.5

Choose a tag to compare

@faysou faysou released this 10 Apr 08:05

Maintenance release

0.4.0

Choose a tag to compare

@faysou faysou released this 01 Sep 07:01

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

Choose a tag to compare

@faysou faysou released this 20 Aug 10:35

Fixed bug in GetSymbolName occuring with Mathematica 11

0.3.2

Choose a tag to compare

@faysou faysou released this 17 Aug 20:56

Fixed ResetClasses
Added fast setter for Dot notation (x.a = 2)

0.3.1

Choose a tag to compare

@faysou faysou released this 17 Aug 08:21

Accelerated function execution in MPlusPlus
Generalised setters and getters in BaseClass for Associations and Lists

0.3.0

Choose a tag to compare

@faysou faysou released this 11 Aug 18:09

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