Class and Interface Declarations

(Up to Analytica.NET)

ClassDef and AObject

An Analytica.ClassDef object defines an Analytica class. It is a .NET managed object, and also an Analytica.Container (i.e., module-like object that contains a sub-hierarchy of objects, which may include methods, variables, etc.). The following depicts the inheritance and a method by which we can obtain a .NET Type object.

 class Analytica.ClassDef : public Analytica.Container {
    public System.Type ToSystemType();         // The .NET description of the class defined by the ClassDef
    public System.Type GetType();              // The .NET description of the ClassDef object.

An Analytica object is an instantiation of an Analytica ClassDef. It is simultaneously an instantiation of a .NET object (since every Analytica-defined object is also a .NET object) and an Analytica container. Therefore, from an Analytica object, you can get two (roughly equivalent) representations of the underlying class:

 class Analytica.AObject : public System.Object {
    public System.Type GetType();           // The standard System.Object method
    public ClassDef GetClassDef();          // The Analyica definition. 

    public String Identifier();
    public Container Parent();   

A call to AObject.GetType() method is equivalent to AObject.GetClassDef().ToSystemType(). But the former is what .NET-compatible applications need to be able to do. The internal representation of a ClassDef object and a System.Type object have a rather different structure as well.

For any given class in Analytica.NET, there will be only one ClassDef object instance in existence. If you were to clone a ClassDef object (not that this is allowed), you would actually end up with a different class, which just happens to have the same members.

The above relationship between an Analytica.AObject and a System.Object, and between an Analytica.ClassDef and a System.Type, is the core concept behind the .NET integration of Analytica.NET.

The System.Type object returned from either AObject.GetType( ) or from ClassDef.ToSystemType( ) is really an instance of an internal derived class that inherits from System.Type( ).

An object's parent container ultimately determines its namespace.


A ClassDef object may contain other AObjects (in the same sense that an Analytica module contains objects), since it inherits from * Analytica.Container. In a ClassDef, these objects may include instantiations of each of the following Analytica.NET classes:

  • Function (a static function)
  • Constructor (a constructor function)
  • Method
  • Attribute (An Analytica Attribute definition, which interacts with dependency maintenance to invalidate downstream results if its value is changed. Beware of potential confusion with .NET's System.Attribute -- a different concept).
  • Variable (a static or member variable. Chance, Decision, etc., are subtypes)
  • ClassDef (Nested classes)
  • Field (A data slot definition. Becomes a field of an instantiated object, but one that has no dependency maintenance functionality, and can be changed directly by external code).
  • Aliases

This list is incomplete and does not explicitly list derived types. See ClassDef Members for details.

Each member of a ClassDef is itself an AObject. Any Analytica.Container (including an Analytica.ClassDef) contains a property Contains that returns a list of all objects directly contained. This list has Function objects, Method objects, etc., all mixed together. The System.Type class separates these out (the ones that are meaningful within .NET) via methods such as GetConstructors( ), GetMethods( ), etc.

AObject Instantiation

A ClassDef constains various other objects (in the same sense that an Analytica module contains objects), among these are Functions. Functions accept parameters, evaluate an expression, and return a value. When a Function is contained within a ClassDef, it is a static function -- you can call it without an object instance.

To a caller, a Constructor is a static function that returns a new instance of the given type. Thus, to create an instance of a new object of a class, you simply call the constructor. A new instance of the object type is created on the stack, the Definition of the constructor is evaluated, and the object itself is returned (not the evaluated value from the constructor's definition).

In C#, etc., the constructors can be accessed using the System.Type.GetConstructor methods. These return a System.Reflection.ConstructorInfo class, whose Invoke method can be invoked to obtain an object instance.

A default constructor (with no parameters) is automatically defined if no explicit user-defined constructor is included. An explicit user-defined constructor is an object have the class Analytica.Constructor (which inherits from Analytica.Function, which indirectly inherits from Analytica.AObject). In most object oriented languages, a constructor usually has the same name as the class itself -- as the namespaces and function overloading specifications are designed, this ought to be considered.

Note that an operator new is not required -- i.e., you don't have to write: new MyClass() -- just MyClassConstructor( ). The Analytica.NET expression syntax needs to make sure this is unambiguous if we aren't going to use the new operator.

The same construction syntax should apply to .NET objects instantiated from Analytica expressions.


The .NET framework allows only for single class inheritance; however, a class can implement any number of interfaces.

Two attributes of a ClassDef define the inheritance.

  • Analytica.Inherits: Accepts either a System.Type for a .NET class, or a Analytica.ClassDef object.
  • Analytica.Implements: A list where each element is either a System.Type for a .NET interface, or an Analytica.Interface object.

An Analytica ClassDef can be used to implement any .NET interface. This is a key functionality that enables integration with .NET applications.

If the Inherits field is set to a .NET class, which is not an Analytica class, then a ClassDef must be treated quite a bit differently. Details need to be worked out.


An custom interface can be defined from Analytica.NET by creating an instance of Analytica.Interface. An Interface definition looks similar in many ways to a ClassDef, except that it can only contain certain types of objects:

  • AbstractFunction
  • AbstractMethod
  • Attribute (as a property)

See Also


You are not allowed to post comments.