login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Meta-classes versus Categories

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.

Expection or fact --yixin.cao, Fri, 25 Jul 2008 00:05:03 -0700 reply
Conceptually, all of these are right.

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 .

  Subject:   Be Bold !!
  ( 14 subscribers )  
Please rate this page: