axiom-developer
[Top][All Lists]
Advanced

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

Re: [Axiom-developer] Aldor extend for extending Axiom code


From: Martin Rubey
Subject: Re: [Axiom-developer] Aldor extend for extending Axiom code
Date: 22 Oct 2006 01:13:33 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

I just checked in the first attempt to an axiom-port of
aldor-combinat. Unfortunately, we won't get anywhere with the current abilities
of axiom and the aldor interface.

Meanwhile, we would need both "extend" and dependent types to work. Details: 

We define LabelType as follows: (the types from libaldor like PrimitiveType are
translated into types for axiom using some source macros)

define LabelType: Category == with {
        PrimitiveType;
        OutputType;
        elements: () -> Generator %;
}

Now we would like to extend the domain with signature 

Set(S:SetCategory): FiniteSetAggregate S == add { ... } to be a combinatorial 
species:

extend Set(L: LabelType): CombinatorialSpecies L == add {
        <<implementation: SetSpecies>>
}

However: "extend" does not work. Well, there is an easy workaround, but it's 
ugly:

IntegerLabel: LabelType with {
        coerce: Integer -> %;
} == add {
        Rep == Integer;
        coerce(a: Integer): % == per a;
        (a: %) = (b: %): Boolean == (rep a) = (rep b);
        coerce(a: %): OutputForm == coerce (rep a);
        import from Integer;
        elements(): Generator % == generate {
                for i: Integer in 1 .. repeat yield per i;
        }
}


The second restriction is more severe. In fact, I think it's a show
stopper. The current signature of Plus is

Plus(
    F: (T: LabelType) -> CombinatorialSpecies(T),
    G: (T: LabelType) -> CombinatorialSpecies(T)
)(L: LabelType): CombinatorialSpecies(L) == add { ... }

Although this compiles and loads well, we get 

)sh Plus
 Plus(F: (LabelType -> CombinatorialSpecies T),G: (LabelType ->
 CombinatorialSpecies T))  is a domain constructor
 Abbreviation for Plus is PLUS 
 This constructor is exposed in this frame.
 Issue )edit species.as to see algebra source code for PLUS 

------------------------------- Operations --------------------------------
 Plus(F,G) is a domain constructor.
 Abbreviation for Plus is PLUS 
 This constructor is exposed in this frame.
 Issue )edit species.as to see algebra source code for PLUS 

------------------------------- Operations --------------------------------


That's it. In fact, we cannot even really try to use it:

(5) -> Plus(SingletonSpecies, SingletonSpecies) IntegerLabel
 
   Although SingletonSpecies is the name of a constructor, a full type 
      must be specified in the context you have used it. Issue )show 
      SingletonSpecies for more information.

depressing.

Martin

Martin Rubey <address@hidden> writes:

> Dear Peter,
> 
> since I managed to have axiom and aldor work together again (I HATE MAKE: 2
> hours), I'm currently trying to get our aldor-combinat package running in
> Axiom, by coding a compatibility layer to libaldor, i.e., reimplementing those
> things we need from libaldor in axiom.
> 
> To this end, it would be great if the "extend" keyword would work. Currently,
> it doesn't seem to.
> 
> Do you have an idea why and - to me probably more important - is there a 
> chance
> to get it running?
> 
> Here is an example file:
> 
> #include "axiom"
> 
> extend Integer: with {
>       foo: % -> %
> } == add {
>       foo(a: %): % == {
>               output("Hi")$OutputPackage; 
>               output(coerce(a))$OutputPackage;
>               output("Ho")$OutputPackage; 
>               a;
>       }
> }
> 
> And here is what I get:
> 
> )co peter.as
>    Compiling AXIOM source code from file peter.as using AXIOM-XL 
>       compiler and options 
> -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra
>       Use the system command )set compiler args to change these 
>       options.
> #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL'
>    Compiling Lisp source code from file ./peter.lsp
>    Issuing )library command for peter
>    Reading /users/rubey/martin/Axiom/peter.asy
>    Integer is already explicitly exposed in frame frame0 
>    Integer will be automatically loaded when needed from 
>       /users/rubey/martin/Axiom/peter
> (1) -> foo 2
>    Hi
>  
>    >> System error:
>    Bind stack overflow.
> 
> (1) -> 1+1
> 
> Integer
>  
>    >> System error:
>    FOAM-USER::|fiRaiseException| is invalid as a function.
> 
> (1) -> foo 2
>    Hi
> Integer
>  
>    >> System error:
>    FOAM-USER::|fiRaiseException| is invalid as a function.
> 
> Martin
> 
> 
> 
> _______________________________________________
> Axiom-developer mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/axiom-developer





reply via email to

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