axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Jenks notes


From: daly
Subject: [Axiom-developer] Jenks notes
Date: Thu, 9 Aug 2007 00:08:47 -0500

Plowing thru my local library I came across this note from Dick Jenks.
Figured it might be of interest.



Every object belongs to a unique class: the class has a name called
the "type" of the object.  An object is called "basic" if the object
is itself not a class of objects.  A "basic class" is a class of basic
objects.

Every class of objects specifies a class of "functions" that usually,
but not necessarily, either create or otherwise manipulate an object
of the class. Functions denote executable procedures which take an
argument and return a value.

Functions are objects. They belong to the class Map (the class of all
maps).  Map is a primitve type whose objects are described by a
signature (syntax) of the form: A -> B where A and B are types.

Classes are objects. They belong to (a metaclass of basic objects
called) a "category".  Categories are objects belonging to the unique
class Category (the class of all categories), a subclass of Class (the
class of all classes).

Primitive types include Category, Class, Map, and Type (the class of 
all types -- that is, the class of all names of possible Axiom classes).
Also primitive are Tuples (of the form (A,...,B)), and Records and
Unions (of the form (a:A,...,b:B)).

A class A is a "subclass" of B (also, B is a "superclass" of A) if
there is an operation: "<: A -> B". The meaning of this operation is:
"If x is an instance of A, then x is also an instance of B". In
general, a class has many superclasses. If A < B and B < A, then A and
B are said to belong to a "class cycle".

Specification is orthogonal to implementation. Moreover, the
represenation of objects of a class need not be records (as is
customary in OOPLs) but may be any other class. Thus a linked list can
be implemented by a record, a sparse vector by a linked list, a sparse
matrix by a sparse vector, a graph by a sparse matrix. The
representation of a category is primitive.

The representation of a class in general is independent of that of a
superclass. the implementation of the operation "<: A -> B" operation
describes how an object of type A must be transformed in order to
become an instance of B.

For example, consider the chain:

 DiagonalMatrix < (BandedMatrix, SquareMatrix) < SquareMatrix
   < Matrix < 2DArray

Here, by the designer's choise, the last 3 use the same representation
(vector of vectors). Diagonal matrices and banded matrices use a more
economical representation. Common operations such as determinant and
trace are exported from the first 3 types, each impleented in their
own economical way. But more obscure operations such as "permanent"
may be defined only on square matrices. To perform this operation, a
banded matrix object must first be converted to a square matrix
operation. 

Categories correspond to abstract classes in C++. Unlike C++, however,
categories have instances, namely the classes of basic objects which
are its members. A category generall "<" another category. Hoever,
since categories all have the same (primitive) representation, the 
"<" operation between categories is always the identity function.

Note however that "<" is not equivalent to "embed". The number 2 is an
integer. Since Integer < RationalNumber, 2 is also a rational
number. However RationalNumber is a field. Since Field < Ring,
RationalNumber is also a ring.

All non-primitive classes are created by maps. The map
  "Integer: () -> Union(EuclideanDomain,OrderedSet,UFD)"
is the operation that creates the class of all integers. Most classes
are created by operations with parameters. The map
  "Fraction: IntegralDomain -> IntegralDomain with .."
is an operation taking a class as an argument and returning a class as
value. RationalNumber is a macro defined as Fraction(Integer).

A category also denotes a class, a metaclass of basic objects, and
therefore is also created by a map. Examples of parameterized
categories are:
  Module: Ring -> Category
  OrderedSet: ((Self,Self) -> Boolean) -> Category
(that is, OrderedSet takes a boolean-valued ordering operation as an
argument. 

A class generally implements methods (functions) for the operations
described by its type. When a method is not prescribed by a class, the
method is found by searching its defaults and its hierarchy.

A purpose of a class hierarchy is to find an operation. If x has class
A and foo(x) is defined, then the foo from A is applied. Otherwise if
A < B, look in B for foo and so on.

The purpose of a category hierarchy is polymorphism. The polymorphic
function sort can be defined as follows:
  S: OrderedSet
  A: FiniteIterableAggregate(S) with shallowlyMutable
  sort(A,(S,S)->Boolean) -> A

The first line means S is of type OrderedSet, a category denoting the
class of all ordered sets. Examples of ordered sets are Integer (the
class of all integers), and so on, which, when defined, declare
themselves to have type OrderedSet, e.g.
  Integer: (...,OrderedSet,...) == implementation

The second line says that A is a finite iterable aggregate with the
"attribute" shallowlyMutable. Such aggreates have finite length and
have an iterator to walk over the successive elements. 
ShallowlyMutable is an attribute meaning that the elements of the
aggregate can be change "in place". Examples of data structures are
lists, strings, vectors, and so on.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]