axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] about Expression Integer


From: Bill Page
Subject: RE: [Axiom-developer] about Expression Integer
Date: Mon, 20 Feb 2006 14:02:25 -0500

On February 20, 2006 12:57 PM Ralf Hemmecke wrote:
> 
> On 02/20/2006 06:15 PM, Gabriel Dos Reis wrote:
> > Ralf Hemmecke <address@hidden> writes:
> > 
> > [...]
> > | Bill Page wrote:
> > | > But eventually in order to program in Axiom, it is 
> > | > essential that they gain a full appreciation of the
> > | > object-oriented design philosophy.
> > | 
> > | I would not really like to call Axiom (or Aldor) object-oriented.
> > | We don't write
> > | 
> > | a.add(b)
> > | 
> > | in order to add two numbers.
> > 
> > There is more to object-orientation than "dot notation".  To my
> > eyes and mind, Aldor and Axiom are object-oriented, and they
> > haven't yet escaped that land :-(
>

I am curious why you wrote :-( ? Are you implying that you wish
that Aldor and Axiom did use a paradigm more advanced than object
orientation?

> Hmm, do you call the following object-oriented?

Before discussing whether something is "object-oriented" or not
I think we need to agree on a definition. For example, I think
the following definition is quite good:

http://www.webopedia.com/TERM/O/object_oriented_programming_OOP.html

object-oriented programming

  A type of programming in which programmers define not only the
  data type of a data structure, but also the types of operations
  (functions) that can be applied to the data structure. In this way,
  the data structure becomes an object that includes both data and
  functions. In addition, programmers can create relationships
  between one object and another. For example, objects can inherit
  characteristics from other objects.

  One of the principal advantages of object-oriented programming
  techniques over procedural programming techniques is that they
  enable programmers to create modules that do not need to be
  changed when a new type of object is added. A programmer can
  simply create a new object that inherits many of its features
  from existing objects. This makes object-oriented programs easier
  to modify.

This definition seems to apply directly to Axiom and Aldor.

BTW, I think the wikipedia definition on the other hand is
terrible!

http://en.wikipedia.org/wiki/Object-oriented_programming

> 
> (This code appears in libalgebra distributed with Aldor and 
> it basically provides a generic function that given a function
> "f: R -> S" returns a function "map(f)" of type "RX -> SX" that
> applies "f" on the coefficients of a univariate polynomial.)
> 
> UnivariateFreeRing2(
>      R : Join(ArithmeticType, ExpressionType),
>      RX: UnivariateFreeRing R,
>      S : Join(ArithmeticType, ExpressionType),
>      SX: UnivariateFreeRing S
> ): with {
>       map: (R -> S) -> RX -> SX;
> } == add {
>       map(f:R -> S)(p:RX):SX == {
>               q:SX := 0;
>               for term in p repeat {
>                       (c, n) := term;
>                       q := add!(q, f c, n);
>               }
>               q;
>       }
> }
> 
> What is the class and what are the methods?
>

Clearly 'UnivariateFreeRing2' is the class and 'map' is a method.
No?

In Axiom terminology this would be called a "package" since it
does not involve any representation object (Rep) and so does
not have any instances (members).

Axiom and Aldor actually implement a two-level class structure
so 'UnivariateFreeRing2' itself is an instance of the class
(category) 'with { map: (R -> S) -> RX -> SX; }'.

Just curious: The syntax:

  map(f:R -> S)(p:RX):SX == {...

looks strangely abbreviated to me. Why not write:

  map(f:R -> S):RX->SX ==

   (p:RX):SX +-> { ...
 
Is this equivalent?

> Can you write that in JAVA or CLOS? I would be happy to see it.

Ignoring for now the details of the Aldor library, why would you
expect this to be difficult? Java supports functions that return
functions anc CLOS is just common lisp done a certain way, so
surely there is no question. Am I missing something?

> 
> > | the function "add" is not attached to the object a. It is 
> > | rather that a and b are on equal footing.
> > 
> > "equal footing" is not contradictory to object orientation.
> 
> Well, you may be right. But when I read about implementation 
> of complex numbers in C++ and saw that a.add(b) construct,
> I really did not like it (at least not in the context of mathematics).
> It is saying: sent the message "add" with parameter "b" to the
> object "a". And it means that "a" has to do the work since "a"
> knows how to add something to itself. It is like saying. The
> integer 1 knows how another integer can be added to it. I don't
> consider that thinking to be quite natural in the context of
> mathematics. I agree, object-orientation be appropriate for other 
> contexts.

What you describe should probably called a "message passing"
paradigm as opposed to object-oriented, as such. Because SmallTalk
was one of the first well known object-oriented languages and
it also implemented the message passing paradigm, I think these
two programming methodologies are sometimes confused.

I Axiom if I write;

  a:Complex Integer := 1
  a + 2

the operation '+' is taken from the domain of 'a'. Both 'a' and
'2' an instances of the class (domain) 'Complex Integer'.

> 
> > | then it becomes clear that Axiom has more to offer that the
> > | current trend in programming.
> 
> > The current trend in programming is some heavy or displaced
> > emphasis on generic programming. 
> 
> Sorry that I don't know CLOS, but I have looked a bit into JAVA's 
> generics. And that is a lot weaker than what was already available
> in Aldor several years ago.
>

I think that is true and these ideas originated in Axiom itself,
which very considerably pre-dates "current trends in programming".
I think it is a pity that Axiom was/is not better known among
programming language designers.
 
> BTW, I don't say that Aldor hasn't some kind of object-orientation,
> but it is in my opinion not a pure object-oriented language.
> 

Define 'pure' ... ;)

Regards,
Bill Page.






reply via email to

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