[Aldor-l] [Axiom-developer] Unions in Spad

Bill Page bill.page at newsynthesis.org
Mon Jul 9 13:29:56 EDT 2007


Ralf,

On 7/9/07, I wrote:
> ...
> Ralf Hemmecke wrote:
> >
> > It looks as if one also could do
> >
> >    if u case MachineInteger then ...
> >
> > with the current Aldor compiler, I just don't know how to type
> > "MachineInteger" since the compiler immediately takes the *type*
> > MachineInteger and not the *tag* MachineInteger.
> >
>
> Use quotes like this?
>
>   'MachineInteger'
>
> That makes in a member of an Enumeration. Maybe that is what Aldor expects?
> ..

Take a look at this example:

http://wiki.axiom-developer.org/SandBoxAldorTesting#msg20070709122631-0500@wiki.axiom-developer.org

#include "axiom"
macro I == Integer;
main():String == {
        import from I, Float;
        U == Union(Integer, Float);
        import from U;
        i: I := 2;
        s: Float := 1.5;
        ui: U := union i;
        us: U := union s;
        u: U := if odd? random(10) then ui else us;
        if u case Integer$'Integer' then {
                "Integer";
        } else {
                "Float";
        }
}

The result is the error message:

Compiler bug...Bug: gen0UnionCaseIndex: branch not in union
   The )library system command was not called after compilation.

So perhaps alll is not well...

Regards,
Bill Page



More information about the Aldor-l mailing list