Impact factor for posts is a measurement of importance.

Impact factor for users reflect their authority, reputation and contribution on a particular topic.

Rating reflects the quality of posts.

Rating on Voofie is not a simple average of all ratings, but a weighted average of rating, weighted by the impact factor of users who rated.

Explore exciting communities of

Documentation of MathOO

05 Nov 10

It is a documentation of MathOO, listing most of its functions and usage.

Bookmark and Share

Content

NewClass

usage:

NewClass[class (,parent1, parent2...)] make a new class which inheritance from parent1, parent2... if parent1, parents ... are provided.

example:

NewClass[UnitTest, Test, Object]

creats UnitTest as a class, which inheritance from Test and Object. The method of inheritance is using C3 method resolution order.

new

usage:

new[class][x, y, ..] creates a new object from the class with x, y, ... as the argument to the constructor of class.

example:

unitTest = new[UnitTest][filename];

creates a new object from the class UnitTest, with filename as the argument to the constructor UnitTest.$init$ and finally assign the new object to x.

Super

usage:

Super[class] returns the parent of class

example:

Super[UnitTest].$init$[unitTest, x] 

calls the parent of UnitTest, which is Test in this case. So, it tries to run:

Test.$init$[unitTest, x]

If Test.$init$ is not provided, MathOO will try to call Object.$init$ instead.

delete

usage:

delete is used to delete a class, an object, or a attributes or method.

example:

delete[x]

deletes the object, or class x. And

delete[x.y]

deletes the attribute or method y from x.

hasAttr

usage:

hasAttr[class,attr] checks whether a class/object has element attr. Notice attr has to be string.

Example:

x = new[Object][];
x.a = 5;
hasAttr[x, "a"]

Output: True

ClassQ

usage:

ClassQ[c] checks whether c is a class or not.

ObjectQ

usage:

ObjectQ[c] checks whether c is an object or not.

ClassObjectQ

usage:

ClassObjectQ[c] checks whether c is an object or a class or not.

static

usage:

static[UnitTest.test] defines test to be a static method of the class UnitTest.

example:

static[UnitTest.error];
UnitTest.error[s_]:=Print["Error :",s];

unitTest.error["overflow"];

This example define the function UnitTest.error as static function. So it does not need the self_ argument. You can call this function from any instance of UnitTest.

Object

usage:

Object is an empty class which only have $init$ defined.

example:

a = new[Object][];
a.x = 1;
a.y = 2;

It creates a object a, which has no attributes defined at all. You can use as a structure to store different variables so that it won't pollute the global namespace.

0 Comments

Please login to post comment.

What is Voofie?

Voofie organizes knowledge, discovers useful resources and recognizes knowledgable users.

Bookmark your blog in Voofie to get more traffic as well as building a reputation in your field!

Explore more about it. Become a member—our FREE Registration takes just seconds.

Page Info
10Impacts
0/0 rates
980
Your Rating:
Version: 4
Last update: 06 Nov 10
History Permalink
Author
Avatar for ross_tang

Ross Tang (ross_tang)

Degree in Physics and Mathematics, Master in Physics
香港

  • Software documentation
  • 0
  • MathOO
  • 0