[Top][All Lists]

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

RE: [Axiom-developer] types as values, and type internals

From: Page, Bill
Subject: RE: [Axiom-developer] types as values, and type internals
Date: Fri, 30 Sep 2005 00:26:58 -0400


This is largely just notes to myself, but if you or any
one else have comments, I would really appreciate it.

On Thursday, September 29, 2005 5:48 PM I wrote:

> ... 
> Given that in the AldorDomain code you write:
>    theIntegerType(): % == per Integer;
> what is the difference in the interpreter when I write:
>   (1) -> A:=Integer
>      (1)  Integer
>                                            Type: Domain
>   (2) -> B:=theIntegerType()
>      (2)  (Integer)
>                                         Type: AldorDomain
> Is there a difference in the internal representations?

I guess the answer must be "yes" since if I use the name
Domain instead of AldorDomain and re-compile the code, this
is the result that I get:

(5) -> x1:=(theIntegerType(),theIntegerType())

   (5)  [(Integer),(Integer)]
                                           Type: Tuple Domain
(6) -> x2:=(Integer,Integer)

   (6)  [(Integer),(Integer)]
                                            Type: Tuple Domain
(7) -> x3:=(1,2)

   (7)  [1,2]
                                    Type: Tuple PositiveInteger
(8) -> select(x3,1)
   Loading /usr/local/axiom/mnt/linux/algebra/TUPLE.o for domain Tuple

   (8)  2
                                           Type: PositiveInteger
(9) -> select(x1,1)

   (9)  Integer
                                                   Type: Domain
(10) -> select(x2,1)

   >> System error:
   Caught fatal error [memory may be damaged]


Back to the drawing board ...

Actually come to think of it, I don't really understand why
just renaming your AldorDomain to Domain is otherwise working
so well for me. Obviously the interpreter is calling the
OutputForm coercion for Integer from 'Domain'. And that makes
the display of Tuple of Domain happy. The tuples x1 and x2
both display the same way, but why can I only select from
the one that was created in 'Domain' but not something that
was created inside Axiom?

Hmmm... you did said earlier I think that Categories and
Domains have a different internal structure?

I suppose then that properly speaking, x1 is a Tuple of Domain
but x2 is "really" a Tuple of the type of Integer, i.e. a
Tuple of SomeCategory(...). It seems that these kinds of
objects don't play nicely with domains. But when encapsulated
in a object from the category embedded in your kind of Domain,
they do.

I cannot write:

(10) -> x:theIntegerType()

   Category, domain or package constructor theIntegerType
      is not available.

because the type of theIntegerType() is the domain Domain,
not some category which is the type of Integer. The
interpreter of course should retract this to a category.

Instead of writing 'theIntegerType()', it would be nice to
use the function you defined: 'make(Integer)'. However this
runs into a similar kind of problem as above since Axiom
does not seem to allow domains to be passed as parameters
to functions even if Aldor specifies the type of the parameter
as a category, e.g. Type. In Axiom I think the only way to
accomplish this is to pass the domain as a parameter to another
domain as shown in the following patch:


diff -au
---     2005-09-29 20:37:51.000000000 -0500
+++      2005-09-29 20:38:13.000000000 -0500
@@ -1,7 +1,7 @@
 #include ""

-AldorDomain: SetCategory with {
-       make: (T: BasicType) -> %;
+AldorDomain(T:Type): SetCategory with {
+       make: () -> %;

        theIntegerType: () -> %;
        map: (%, %) -> %;
@@ -34,7 +34,7 @@

        import from Rep2;

-       make(T: BasicType): % == per T;
+       make(): % == per T;
        theIntegerType(): % == per Integer;
        integerMod(p: PositiveInteger): % == per(IntegerMod p);


(1) -> )abb dom AD AldorDomain
   AD abbreviates domain AldorDomain
(1) -> )lib domain2
   Reading /home/page/domain2.asy
   AldorDomain is now explicitly exposed in frame initial
   AldorDomain will be automatically loaded when needed from
(1) -> a:=make()$AD(INT)

   (1)  (Integer)
                                   Type: AldorDomain Integer
(2) -> b:=make()$AD(FLOAT)

   (2)  (Float)
                                     Type: AldorDomain Float
(3) -> c:Tuple Any:=(a,b)

   (3)  [(Integer),(Float)]
                                             Type: Tuple Any
(4) -> select(c,1)

   (4)  (Float)
                                     Type: AldorDomain Float


See also revised web page:

Bill Page.

reply via email to

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