[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] Aldor extend usable in Axiom???
From: |
Peter Broadbery |
Subject: |
Re: [Axiom-developer] Aldor extend usable in Axiom??? |
Date: |
Mon, 27 Nov 2006 13:17:02 +0000 |
On Mon, 2006-11-27 at 12:21 +0100, Ralf wrote:
> Hello,
>
> I am quite a bit frustrated.
>
> It is clearly not a problem (up to something I have not yet looked into)
> to extend existing Axiom domains from libaxiom.al via some .as files.
> The question now is: How do I use them?
>
> Try
>
> #include "axiom"
> extend Integer: with {foo: % ->%} == add {foo(x:%):%==x}
>
> compilation with )compile is no problem, but when I then type
>
> 1
>
> I run into a foam error.
>
I've been looking at this on and off, and haven't come to a good
solution, so this mail is as much to see if anyone else wants to look at
the problem as it is do describe what axiom is doing.
The foam error is 'Circular get encountered' or similar, followed by a
lack of exception raising machinery. Defining 'fiRaiseException' to
simply throw its argument will do the job here, I expect.
The underlying problem here is that aldor is expecting that the axiom
domain 'Integer' will not be replaced by the new aldor one - however, in
an interpreted environment that is exactly what happens. As an aside,
in compiled code aldor assigns a hashcode to each extended and
non-extended domain, so they are all kept seperately, and in theory one
can do extends with lexical as opposed to global scope).
In more detail (only the really enthusiastic should keep reading), when
the axiom domain is imported into the aldor runtime (daase.lisp,
process-import-entry), the aldor name is assigned to a domain which is
lazily expanded to the axiom definition of a domain - the lazy expansion
is in interop.boot. Of course, the load process changes the axiom
definition of the extended domain to be the new aldor one, and a rather
nasty circularity ensues.
There seem to be two ways of fixing this - either 'rescue' the original
domain, and make sure that aldor code can only reference it, or rewrite
the lookup routines to use the underlying axiom style function lookup
vectors (of which I have no real knowledge).
In either case, the 'extend' case needs to be handled seperately,
because in the normal course of events, one expects 'Integer' to be the
latest one loaded into the system.
Peter