edu.vub.at.objects
Interface TypeTag


 TypeTag

The public interface to a native type tag object.

Type tags consist of two properties:

Types have one important operation: one type can be tested to be a subtype of another type.

Type tags are very similar to empty Java-like interface types, and their main purpose lies in the *classification* of objects. AmbientTalk Objects can be tagged with zero or more type tags.

Author:
tvcutsem

Method Summary
 Object annotateMessage(Object originalMessage)
          Invoked on a type tag when the type tag is used to annotate asynchronous message sends.
 Method annotateMethod(Method originalMethod)
          Invoked on a type tag when the type tag is used to annotate method definitions.
 Boolean isSubtypeOf(TypeTag other)
          Returns true if this type tag is a subtype of a given type tag.
 Table superTypes()
          Returns a table with the supertypes of this type tag.
 Symbol typeName()
          Returns the name of this type tag.
 
Methods inherited from interface edu.vub.at.objects.Object
super
 

Method Detail

typeName

Symbol typeName()
Returns the name of this type tag.

Returns:
an Symbol representing the unique name by which the type can be identified.

superTypes

Table superTypes()
Returns a table with the supertypes of this type tag.

Returns:
an Table with the super types of the receiver type tags.

isSubtypeOf

Boolean isSubtypeOf(TypeTag other)
Returns true if this type tag is a subtype of a given type tag.

More specifically, what the native implementation (expressed in AmbientTalk syntax) does is:

def isSubtypeOf(supertype) { (supertype.name() == name).or: { (supertypes.find: { |stype| stype.isSubtypeOf(supertype) }) != nil } };

Parameters:
other - a type.
Returns:
true if the receiver type is a subtype of the other type.

annotateMessage

Object annotateMessage(Object originalMessage)
Invoked on a type tag when the type tag is used to annotate asynchronous message sends. E.g. when invoking: obj<-m(args)@Type The interpreter will invoke: Type.annotateMessage(msg) where msg is the message <-m(args) The return value of the annotate method is an extended message which will be used during message sending. When a message is annotated with multiple type tags, the annotate methods of these different type tags are chained to produce the final message.

Parameters:
originalMessage - the message to annotate
Returns:
the annotated message (the message extended with metadata)

annotateMethod

Method annotateMethod(Method originalMethod)
Invoked on a type tag when the type tag is used to annotate method definitions. E.g. when evaluating: def method(arg1, ..., argN) @Type { ... } the interpreter will invoke Type.annotateMethod(meth) where meth is a method object with the given name, arguments and body. The return value of the annotateMethod is an extended method object which will be installed in the method dictionary. The object can override e.g. apply to intervene when the method is being applied. When a method definition is annotated with multiple type tags, the annotate methods of these different type tags are chained to produced the final method object.

Parameters:
originalMethod - the method to annotate
Returns:
the annotated method (the method with additional metadata)