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: Ralf Hemmecke
Subject: Re: [Axiom-developer] Unions in Spad
Date: Fri, 13 Jul 2007 21:10:33 +0200
User-agent: Thunderbird 2.0.0.4 (X11/20070604)

>> So you can see from your example that i1 and i2 give, respectively,
>>  (0 . 1) and (0 . 2), thus inj1 and inj2 are placing their values
>> in the tag1 field.
> 
> This simple representation limits the generality and naturalness of
> implementation. But where are the tags?


Compile the following program with
aldor -flsp -fc -laldor aaa.as
and grep generated the lisp and c sources for "tag1".
You will not find it.

Why do you think that limits the generality of the implementation. Why
do you think "tag1" is important in generated code?

If you create something of the form Union(foo:Integer,bar:Integer) you
get exactly the same representation in the generated file, but still as
aldor code you cannot turn an element of

Union(foo:Integer,bar:Integer)

into

Union(tag1:Integer,tag2:Integer)

since these are two different types.

Ralf

-----------------
#pile
#include "aldor"
#include "aldorio"

Bar : Exp == Impl where
  Exp ==> with
    inj1 : Integer -> %
    prj1 : % -> Integer
  Impl ==> add
    Rep == Union(tag1: Integer, tag2: Integer)
    import from Rep
    inj1(n : Integer) : % == per [tag1==n]
    prj1(p: %): Integer == (rep p).tag1

main(): () == {
  z: Integer := 1;
  b1: Bar := inj1 z;
  stdout << "prj1 b1 = " << prj1 b1 << newline;
}
main();
-------------------




reply via email to

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