axiom-developer
[Top][All Lists]
Advanced

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

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


From: Peter Broadbery
Subject: RE: [Axiom-developer] types as values, and type internals
Date: Thu, 29 Sep 2005 20:21:26 +0100

On Thu, 2005-09-29 at 03:36 -0400, Page, Bill wrote:
> Peter,
> 
> I am quite interested in your ideas about providing
> something equivalent to java.lang.reflect in Aldor and
> Axoim. I think this might also be useful to solve the
> problem with an undefined function |domain| which appears
> when writing for example:
> 
> (1) ->  (Integer,Float)
> 

It was written mostly to show that you could do some operations on
domains - effectively allowing one to write more of an interpreter in
the extension language.  I'm not 100% confident of what the definitions
of "Domain", "SubDomain", "Category" and "Type" should be, so was
avoiding them.

If we can find a way that these can fit together and allow axiom to deal
with them coherently it would definitely be a good thing, but I'm not
sure I'm qualified to decide exactly what the semantics should be. 

> I wonder if the the Rep == Type really makes sense?
> 

I think Rep ==> Type is more or less honest, given that a Type is an
object in the aldor world view. A  caveat is that it captures categories
(and "Type") as well as domains.  

> On Monday, September 26, 2005 4:41 PM Peter Broadbery wrote:
> 
> > 
> > As usual, should have done a bit more testing; use the
> > attached domain2.as - it makes map work a bit better.
> > 
> > a := map(theIntegerType(), theIntegerType())
> > lookup(theIntegerType(), "-", a);
> > 
> > works, but axiom will not display the object returned by
> > lookup - it's expecting an SExpression (ie a list of lispy
> > values), and we're feeding it a more complex structure.
> > 
> 
> The stuff in interop.boot seems very obscure to me but
> I am gradually absorbing a little.
> 

Yes - it is obscure.  Unfortunately it seemed to be the best solution at
the time, and then we hacked it about a little.  The trick is to try and
untangle it again.  There are (at least) two ways domains are treated -
one is as S-Expression, eg (|List| (|Integer|)) and the other is the
aldor "Rep2" object - in general axiom code handles both, while aldor
will only accept the latter.

> Here's a simple patch that actually prints domain names by
> calling devaluate() instead of manipulating the domain as
> a record structure. There must also be something subtley
> wrong with Rep2?
> 

Devaluate should be equivalent for all domains.  Ah, Mappings aren't
quite domains, since  'isDomain' fails for them.  Not sure what the
underlying bug is though. 

> Patch follows:
> 
> --------
> 
> address@hidden page]$ diff -au domain2.as.orig domain2.as.new
> --- domain2.as.orig     2005-09-29 02:02:13.000000000 -0500
> +++ domain2.as.new      2005-09-29 02:02:34.000000000 -0500
> @@ -1,6 +1,6 @@
>  #include "axiom.as"
> 
> -AldorDomain: BasicType with {
> +AldorDomain: SetCategory with {
>         make: (T: BasicType) -> %;
> 
>         theIntegerType: () -> %;
> @@ -17,8 +17,8 @@
> 
>  } == add {
>         import {
> -               BOOT_:_:DNameToSExpr: SExpression -> SExpression;
>                 BOOT_:_:hashString: SExpression -> SExpression;
> +                BOOT_:_:devaluate: SExpression -> SExpression;
>         } from Foreign Lisp;
> 
>         Rep  ==> Type;
> @@ -51,12 +51,12 @@
> 
>         coerce(t: %): OutputForm == {
>                 import from String;
> -               "<SomeType>"::OutputForm
> +               name(t)::OutputForm
>         }
> 
>         name(t: %): SExpression == {
> -               dom := t pretend Rep2;
> -               axiomName((dom.v.domName)(dom.o))
> +                dom := t pretend SExpression;
> +                devaluate(dom);
>         }
> 
>         -- nb: cf. interop.boot, basicLookup
> @@ -81,9 +81,9 @@
>                 integer((dom.v.hashCode)(dom.o))
>         }
> 
> -       local axiomName(s: SExpression): SExpression == {
> -               BOOT_:_:DNameToSExpr(s);
> -       }
> +        local devaluate(s: SExpression): SExpression == {
> +                BOOT_:_:devaluate(s);
> +        }
> 
>         local hashString(s: SExpression): SExpression == {
>                 BOOT_:_:hashString(s);
> 
> -------
> 
> Regards,
> Bill Page.
-- 
Peter Broadbery <address@hidden>




reply via email to

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