|
|
last edited 16 years ago by alfredo |
1 2 3 4 | ||
Editor: alfredo
Time: 2008/07/25 07:26:47 GMT-7 |
||
Note: |
changed: -Axoim domains are like Axiom domains are like
Axiom has a two-level type system consisting of categories and domains.
Axiom domains are like classes in the sense of object-oriented programming however there are some differences. The instances of classes are called objects. Objects inherit all the methods defined in a class. Instances of domains on the other hand are just "values". For example "-1" as an object in a class named "Integer" provides basic arithmetic operations like "+" and "*" with which it can interact. In effect we "ask" -1 to add itself to some other number. As a value of the domain Integer, -1 is just a value. It carries no type information in itself except that it is a member of this domain. In most cases operations involving the creation of values of a given domain are provided by the domain to which the value belongs, but operations involving its members will often be selected from domains other than Integer.
This distinction between classes and domains is also related to static versus dynamic typing
Each domain must satisfy one or more categories. Categories specify the external interface, i.e. what methods a domain exports plus optional default implementations of some of these methods. For example the domain Integer "has" the category IntegerNumberSystem?. In addition to specifying an interface, categories serve as "predicates" which group domains according to the intended properties that all such domains are intended to share. This is how mathematical concepts are represented in Axiom.
All types (domains and categories) in Axiom are "first-order", i.e. they have some representation at run-time. They can be stored as values of variables and they can be passed and returned as values of functions. In other words Axiom domains are themselves objects.
An Axiom category is similar to a meta-class in object-oriented programming. A meta-class is a class whose objects are classes in their own right. In Axiom however domains are not instances of categories. Categories do not provide operations which create domains, rather in it's definition a domain is statically declared to satisfy a given set of categories.
But, in current Axiom systems, first, Categories don't specify the external interface for domains, if the "specify" indicates mandatory relation; second, neither domains nor categories are already "first-order", according to the definition by Christopher Strachey, see http://en.wikipedia.org/wiki/First-class_object .