Aztec® Programming Language

Version 1.0 Alpha

Copyright © 2010-2013

Cold Spring® Development Group

All Rights Reserved

Download Aztec

Site Help

♦ Aztec classes can be defined in multiple places. There can only be one primary definition of a class, and it must not use ‘satellite’ keyword. There can be any number of satellite definitions (across multiple modules), and each must be marked with the ‘satellite’ keyword.

♦ You can add instance methods (including new constructors), shared methods and shared data to the class by defining them in a satellite class block.

♦ You can not add new instance data items to a class.

♦ Primitive data types currently do not support instance methods in satellite classes, but they do allow shared methods and shared data. This restriction may be removed in the future.

♦ Allows new functionality to be added to a class without having to create a new class

♦ Provides flexibility in controlling access to data and methods when satellites are used together with visibility options such as ‘module’, ‘family’, ‘space’ and ‘unit’.

♦ A class must be defined with the ‘dynamic’ keyword in order to allow satellite classes to be defined for it. ALL classes in the Aztec Framework are defined as dynamic.

♦ Future Aztec plans include adding the ability to dynamically compile code while the VM is running and make the new code available to the running script. Using a satellite class in dynamically compiled code allows methods and shared data to be added to the class at run-time.

♦ Full source code examples showing Satellite Class usage

 
#===============================================================================
#                                  Example 1
#===============================================================================

public class Main from<Thread>
{
    public method Main()
    {
        Thread()						# Must invoke base constructor.
    }
public virtual method Run { data<List> MyList MyList = new<List(self)> # Uses constructor defined below. } } #------------------------------------------------------------------------- # This satellite class adds a new constructor to the Aztec 'List' class. #-------------------------------------------------------------------------
public satellite class aztec.util.List
{
    # User defined constructor attached to an existing class.
    public method List(Base FirstItem)
    {
        data<Thread>    ThreadRef

        # Call the "real" constructor and then add the first item.
        self.List()
        AddItem(FirstItem)

        # Retrieve the item we just added and write it to the log.
        ThreadRef = GetItem(1) as type<Thread>
        GetScript().WriteLog("Thread Id using custom constructor: " + ThreadRef.ThreadId().Str())
    }
}

#===============================================================================
#                                  Example 2
#===============================================================================

# ---------------------------- Module1.aztec ----------------------------
      
public method Main
{
    data<Test2>    MyTest2 = new<Test2>
}

# Main definition of the class Test1. Must be marked as 'dynamic'.
public dynamic class Test1
{
    public method Test1
    {
    }
# This method is visible only within this class. private method Method1() {
} } # ---------------------------- Module2.aztec ---------------------------- public satellite class Test1 { # This method is visible within this class AND this module. module method Method2() { GetScript().WriteLog("Inside Method2!!!") } } public class Test2 {
public method Test2() { data<Test1> Test1Ref
Test1Ref = new<Test1> Test1Ref.Method2() # Valid since Method2 is marked as 'module' # and it is defined inside this module. } }

Page UpPage DownCopyright © 2010-2013
Cold Spring Development Group
All Rights Reserved

Download Aztec