axiom-developer
[Top][All Lists]
Advanced

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

Re: [Axiom-developer] Unions in Spad


From: Bill Page
Subject: Re: [Axiom-developer] Unions in Spad
Date: Mon, 9 Jul 2007 13:29:56 -0400

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/address@hidden

#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




reply via email to

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