Hello Stephen,
Regular Unions do not have tags associated with branches. For example:
Union(Integer, String)
New Unions have tags, as in
Union(int: Integer, str: String)
SPAD seems to allow
u: Union(Integer, String) := ...
if u case Integer then ...
I am not aware of the fact that Aldor can do this. And in the Aldor User
Guide I have only found tagged unions.
How does now actually distinguish branches. My code above was actually
only a guess. I have no idea whether that works in SPAD. In Aldor it
doesn't.
Ralf
woodpecker:~/scratch>aldor -laldor -fx aaa.as
"aaa.as", line 13: if u case MachineInteger then {
..................^
[L13 C19] #1 (Error) Argument 2 of `case' did not match any possible
parameter type.
The rejected type is Join(
PrimitiveType with
....
Expected one of:
-- Enumeration(MachineInteger: Type)
-- Enumeration(String: Type)
---BEGIN aaa.as
#include "aldor"
#include "aldorio"
macro I == MachineInteger;
main(): () == {
import from I, String;
U == Union(MachineInteger, String);
import from U;
i: I := 2;
s: String := "I am a string";
ui: U := union i;
us: U := union s;
u: U := if odd? random(10) then ui else us;
if u case MachineInteger then {
stdout << "Integer: " << newline;
} else {
stdout << "String: " << newline;
}
}
main();---END aaa.as
_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer