On 7/9/07, Ralf Hemmecke <[EMAIL PROTECTED]> wrote:
...
Bill Page wrote:
> Use quotes like this?
>
> 'MachineInteger'
>
> That makes in a member of an Enumeration. Maybe that is what Aldor expects?
...
But, of course it must fail.
'MachineInteger'
is nothing else than
Enumeration(MachineInteger: Type)
but what I need is an element of this enumeration type.
Sorry. I should have written MachineInteger$'MachineInteger' I think
that is the correct explicit notation of the element. Or you can
import from 'MachineInteger'.
It seems that MachineInteger is rather special. Look at the following
session.
Ralf
woodpecker:~/scratch>aldor -gloop
AA L DDDD OOO RRRR
A A L D D O O R R
A A L D D O O R R
AAAAA L D D O O RRRR
A A L D D O O R R
A A LLLLL DDDD OOO R R
(c) Numerical Algorithms Group Ltd 1995-2001
Release: Aldor(C) version 1.0.3 for LINUX(glibc2.3) (debug version)
Type "#int help" for more details.
%1 >> #include "aldor"
Comp: 190 msec, Interp: 50 msec
%2 >> #include "aldorinterp"
Comp: 80 msec, Interp: 0 msec
%3 >> MyDom: with == add;
Defined MyDom @
with
== add ()
Comp: 10 msec, Interp: 0 msec
%4 >> MyDom
() @
with
== add ()
Comp: 0 msec, Interp: 0 msec
%5 >> import from 'MyDom'
Comp: 0 msec, Interp: 0 msec
%6 >> MyDom
^
[L6 C1] #1 (Error) Have determined 2 possible types for the expression.
Meaning 1:
with
== add ()
...
Meaning 2: Enumeration(MyDom: Type)
This makes sense because of the import, right? Aldor cannot tell from
the context which one you mean.
%7 >> MachineInteger
() @ Join(
PrimitiveType with
0: %
1: %
-: (%, %) -> %
bytes: %
coerce: SInt -> %
coerce: % -> SInt
integer: Literal -> %
min: %
max: %
odd?: % -> Boolean
zero?: % -> Boolean
== add ()
,
Join(CopyableType, IntegerType) with
mod+: (%, %, %) -> %
mod-: (%, %, %) -> %
mod*: (%, %, %) -> %
mod/: (%, %, %) -> %
mod^: (%, %, %) -> %
modInverse: (%, %) -> %
export to IntegerSegment(%)
== add ()
,
with
== add ()
)
Comp: 0 msec, Interp: 0 msec
%8 >> import from 'MachineInteger'
Comp: 10 msec, Interp: 0 msec
%9 >> MachineInteger
() @ Join(
PrimitiveType with
0: %
1: %
-: (%, %) -> %
bytes: %
coerce: SInt -> %
coerce: % -> SInt
integer: Literal -> %
min: %
max: %
odd?: % -> Boolean
zero?: % -> Boolean
== add ()
,
Join(CopyableType, IntegerType) with
mod+: (%, %, %) -> %
mod-: (%, %, %) -> %
mod*: (%, %, %) -> %
mod/: (%, %, %) -> %
mod^: (%, %, %) -> %
modInverse: (%, %) -> %
export to IntegerSegment(%)
== add ()
,
with
== add ()
)
Comp: 0 msec, Interp: 0 msec
Interesting. I would have expected the same error as above.
But try to compile
---BEGIN aaa.as
#include "aldor"
#include "aldorio"
macro I == MachineInteger;
M1: with == add;
main(): () == {
U == Union(M1, String);
import from String;
import from U;
import from 'M1';
s: String := "I am a string";
u: U := union s;
if u case M1 then {
stdout << "Integer: " << newline;
} else {
stdout << "String: " << newline;
}
}
main();
---END aaa.as
woodpecker:~/scratch>aldor -laldor -fx aaa.as
Compiler bug...Bug: gen0UnionCaseIndex: branch not in union
Cool!
Cool? That is the same error that I get if I write
U == Union(Integer, String);
u:U := ...
if u case Integer$'Integer' then ...
http://wiki.axiom-developer.org/[EMAIL PROTECTED]
Any, I think you were right the first. It was the intention of the
Aldor developers that an untagged Union should be possible. It just
seems that there is an error in the compiler that currently prevents
this.
Regards,
Bill Page.
_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer