Recent Changes in Language Module

  • Added several function tables to perform sequence operations - SequenceFunctions, VarSequenceFunctions - giving functions like c(...), rep() and cycle.
    Use addFunctionTable(SequenceFunctions) to access these.
  • Added general subset overloading via interpreted and utility functions (addFunctionTable access) and implemented some examples for XML.
  • Lazy and variable argument lists handled by internal compiled functions added to the evaluator via addFunctionTable
    Some examples can be found in OmegahatVarArgsSystemFunctions, OmegahatVarArgsSystemFunctions such as Switch(), time() and Quote()
      x = "a"     
      Switch(x,a=1, b=10, c="z");
      time(foo(y));
      Quote(1::20 + 1)     
    
  • Introduction of the global keyword to allow interpreted user-level class methods to refer to global methods and functions without conflicting with methods local to the class.
  • Compiled user-level classes supporting interpreted methods.
    • Can use instances of and the class itself as a regular Java class in other calls.
    • Can edit a method/constructor at any time in the life of a class and have it propogated to all instances, providing rapid editing of the definitions of methods.
    • Dynamic debugging using the omegahat evaluation model and facilities.
    • Cannot add new methods after the associated Java class has been compiled/generated.
    • Methods that override ones in the base class are given the same type.
    • Methods can refer to other methods
           class Dummy extends util.Vector {
              function addElement(x) {
                if(x instanceof String)
                   x = x.trim();
                super.addElement(x);
              }
               
    
              function foo() {
                
              }
           }
          
  • Enhanced byte-code generation facilities.
    A side effect of adding byte compilation for classes, etc. is that there are now signficantly more high-level facilities for general use in gtenerating byte-code. See DynamicCompiler, EvaluableInterfaceGenerator and UserClassGenerator
  • Methods in user-level classes can find methods in the implicit this rather than looking up global functions or methods (i.e. evaluator methods).
            class A extends util.Vector {
             function addElement() {
               ..
              size();  // size method in A (inherited from Vector) 
              trim(x); // "global" scoped method
             }
           }
          
  • Added casting support
    Suppose that B extends a class A and that each defines a method foo() returning the name of the class (B and A, respecitively). Invoking the method directly on an instance of B gives the result B. Casting the instance to A and invoking the method on the resulting reference gives A
             [] b = new B()
             [] b.foo()
             B
             [] ((A)b).foo()
             A
          
  • Optional single container for Class lists. (Sun Oct 3 '99)
    The recursive class lists introduce earlier allowed one to move sub-package lists around within a package and also between packages. The GroupedClassList collapses the divide between packages and collects all the sub-packages into a single container. This facilitates moving sub-packages between packages so as to affect the order of lookup of classes in the system, not just within a package.

    Whether this is used or the old group-by-package class is used is controlled by the option groupedClassList which should be true or false. This can be specified on the command line as -DgroupedClassList=true or in the OmegaOptions as groupedClassList: true

    Note that it cannot be effectively set in one's .omegahatrc file as the class list will have been created at this point.

  • Class lists grouped by directory. (Sat Oct 2 '99)
    The class lists are now (by default) recursive, storing groups of classes by directory in their own sub-ClassList objects. This allows one to move, remove and migrate these objects from a ClassList and alter the search for classes. For example, there are two classes named numeric in the Omegahat package(s). Because of the way the directories are list, the class DataStructures.numeric is found before ObjectDataStructures.numeric To change this, we can simply remove the entry org/omegahat/Environment/ObjectDataStructures from the appropriate entry in the classLists() object.
          [] numeric
          class org.omegahat.Environment.DataStructures.numeric
          [] classLists()[[0]].remove("org/omegahat/Environment/ObjectDataStructures")
          [] numeric
          class org.omegahat.Environment.ObjectDataStructures.numeric
    
    (Obviously, the position 0 may not be the appropriate element. This depends on the value of the user's CLASSPATH. We can check which entry we want with the command
     [] classLists().orderedKeys()
     [/home/duncan/Scratch/org/.., /home/duncan/Scratch/org/omegahat/Jars/swingall.jar, /usr/local/src/jdk1.2/lib/classes.zip, /home/duncan/Scratch/org/omegahat/Jars/antlr.jar, /home/duncan/Scratch/org/omegahat/Jars/jas.jar, /home/duncan/Scratch/org/omegahat/Jars/jhall.jar, /u3/local/src/jdk1.2/jre/lib/rt.jar, /u3/local/src/jdk1.2/jre/lib/i18n.jar, /u3/local/src/jdk1.2/jre/classes]      
    
    So we could use the command
     [] classLists()[[new File("/home/duncan/Scratch/org/..")]].remove("org/omegahat/Environment/ObjectDataStructures")
    
    If the CLASSPATH variable is is not set, the omegahat script arranges to have the Omegahat packages located first in the list.
  • Precedence of ^ and % operators increased. Tues 28 Sept. '99
    The precedence of these two operators is now higher than *, / and :.
  • Operator overloading (Fri 17 Sep. 99)
    Some of the cases for array math operations have been added to MathExpression in the method MathExpression.
    [1] x= new double[]{1,2,3}
    1.0
    2.0
    3.0
    [2] x + 10
    11.0
    12.0
    13.0
    [3] x + new double[]{10,100}
    11.0
    102.0
    13.0
    [4] x - 100
    -99.0
    -98.0
    -97.0      
    
    There are still cases that this does not cover. This is in response to David Jame's report.
  • Named Utility Functions (Fri 17 Sep. 99)
    Classes and instances registered as Utility Functions can be given a name via the addFunctionTable method in the evaluator. This defaults to the class name of the object (with the package stripped away). This allows more specific resolution of "function" calls, in addition to the usual facilities offered by these "functions".
    See asObject.
  • Utility Functions
    Ability to add arbitrary objects and classes (with static methods) to a list that is searched to resolve function-like calls (i.e. no qualifier in a method invocation)
  • Automatica coercion between numbers
    Method matching when a primitive or object-instance corresponding to a primitive (i.e. Double, Integer, etc.) is supplied or required and a "compatible" object is supplied. Currently supports converting between the basic number classes (e.g. double to integer, integer to double, ...) For example,
        [1] x = new util.Vector(); x[[0]] = "foo"
        [2] x.elementAt(0.)  // note that 0. is a Double
    
    will now match the method java.util.Vector.elementAt(int) See MethodCall.transformArguments() and MethodLocator.matchClass()

    This breaks some of the method dispatching.


  • Duncan Temple Lang <duncan@research.bell-labs.com>
    Last modified: Fri Oct 22 17:02:22 PDT 1999