axiom-developer
[Top][All Lists]
Advanced

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

[Axiom-developer] Generator <---> Stream


From: Ralf Hemmecke
Subject: [Axiom-developer] Generator <---> Stream
Date: Sun, 10 Dec 2006 14:21:31 +0100 (MET)
User-agent: Thunderbird 1.5.0.8 (X11/20061025)

Since nobody answered my previous Generator question, here is another problem.

How can I convert back and forth between Aldor-Generator and Axiom-Stream?

It is not trivial, since I cannot use the export

generate: (()->S) -> %

from Stream(S), because 'generate' is a keyword in Aldor.

So I looked up its definition and wrote

---BEGIN gentst.as
#include "axiom"
macro Z == Integer;

extend Stream(T: Type): with {
--      mygenerate: (()->T) -> %;
        coerce: Generator T -> %;
} == add {
        local mygenerate(f: () -> T): % == delay concat(f(), mygenerate f);
        local rhxnext!(g: Generator T)(): T == {
                for t in g repeat return t;
                0$Z pretend T;
        }
        coerce(g: Generator T): % == mygenerate rhxnext! g;
}
---END gentst.as

But compilation gave me the following

woodpecker:~/scratch>woodpecker:atch>aldor -Y . -Y $ALDORROOT/lib -I $ALDORROOT/include -dAxiom -q1 -Fasy -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -Y /home/hemmecke/software/Axiom/mnt/linux/algebra -fao -M2 -Mno-abbrev gentst.as
"gentst.as", line 8:
        local mygenerate(f: () -> T): % == delay concat(f(), mygenerate f);
...........................................^
[L8 C44] #1 (Fatal Error) Compiler bug: unsupported absyn (Delay) found by genFoam.

Any help is much appreciated.

Why do I need that? I have an Aldor function that returns Generator(T). I am able to call that function in an Axiom session, but I cannot iterate over such a result, i.e. if g:Generator(T) then

for t in g repeat ....

does not work inside Axiom. :-(

Ralf




reply via email to

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