From bill.page at newsynthesis.org  Thu Jul  5 03:17:04 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Thu, 5 Jul 2007 03:17:04 -0400
Subject: [Aldor-l] [Axiom-developer] Problem kTuple wish 2.
In-Reply-To: <46810445.8010705@hemmecke.de>
References: <119483.36899.qm@web56712.mail.re3.yahoo.com>
	<87hcovybi7.fsf@lattice.localdomain>
	<9q4pkvd8nl.fsf@aquin.mat.univie.ac.at>
	<87d4zjyaor.fsf@lattice.localdomain>
	<9qsl8f449v.fsf@aquin.mat.univie.ac.at>
	<87wsxrw0pc.fsf@lattice.localdomain>
	<9q8xa7c90i.fsf@aquin.mat.univie.ac.at>
	<9q645b2dds.fsf@aquin.mat.univie.ac.at> <46810445.8010705@hemmecke.de>
Message-ID: <fbcd16d40707050017x7f7e7579yd2c976c898f72ef@mail.gmail.com>

On 6/26/07, Ralf Hemmecke wrote:
> ...
> Suppose you want a constructor like
>
> M(T: Tuple Cat): MCat(T) == add {...}
>
> for some given category Cat (For simplicity, lets say
>
>    define Cat: Category == with {=:(%,%)->Boolean}
>
> . The question now is how do I define MCat and the corresponding add
> {...} in such a way that I am able to generate an element of M in a
> simple form.
> ...

I tried to see how far I could get with this problem in Aldor. The
result is shown at:

http://wiki.axiom-developer.org/SandBoxAldorTuples

The code compiles and is apparently type correct but it does not
exactly produce the expected output. This code seems to work best
compiled to Lisp and iinked into Axiom. When I try the same thing with
the Aldor stand alone compiler I get some peculiar and unexpected
error messages. Perhaps this is pushing the limits of what the
compiler can do but I seems to be almost there... Perhaps a bug report
is in order?

Regards,
Bill Page.


From ralf at hemmecke.de  Thu Jul  5 06:03:18 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Thu, 05 Jul 2007 12:03:18 +0200
Subject: [Aldor-l] [Axiom-developer] Problem kTuple wish 2.
In-Reply-To: <fbcd16d40707050017x7f7e7579yd2c976c898f72ef@mail.gmail.com>
References: <119483.36899.qm@web56712.mail.re3.yahoo.com>	
	<87hcovybi7.fsf@lattice.localdomain>	
	<9q4pkvd8nl.fsf@aquin.mat.univie.ac.at>	
	<87d4zjyaor.fsf@lattice.localdomain>	
	<9qsl8f449v.fsf@aquin.mat.univie.ac.at>	
	<87wsxrw0pc.fsf@lattice.localdomain>	
	<9q8xa7c90i.fsf@aquin.mat.univie.ac.at>	
	<9q645b2dds.fsf@aquin.mat.univie.ac.at>
	<46810445.8010705@hemmecke.de>
	<fbcd16d40707050017x7f7e7579yd2c976c898f72ef@mail.gmail.com>
Message-ID: <468CC1E6.7010409@hemmecke.de>

> http://wiki.axiom-developer.org/SandBoxAldorTuples

Thank you, Bill. I think, I love the idea with

   get: % -> T

But that is only a tiny bit and actually does not solve the problem that 
  I finally would like to return something like

(F Integer, F String)

for some domain constructor F if the input T is (Integer,String).

> The code compiles and is apparently type correct but it does not
> exactly produce the expected output. This code seems to work best
> compiled to Lisp and iinked into Axiom. When I try the same thing with
> the Aldor stand alone compiler I get some peculiar and unexpected
> error messages. Perhaps this is pushing the limits of what the
> compiler can do but I seems to be almost there... Perhaps a bug report
> is in order?

To make that error message clearer I realized to following:

woodpecker:~/scratch>aldor -fx -laldor aaa.as
woodpecker:~/scratch>aaa
Looking in M((AldorInteger, String)) for m with code 111396431
Unhandled Exception: RuntimeError()
Export not found

for the program given below. To me that looks like a compiler bug.

To be honest, I am not sure whether the compiler should actually compile 
that code without complaint.

If one writes

   m(4, "a)                             (*)

then what is

   (4, "a")                             (**)

? A multi-value. But m cannot be applied to multivalues. It needs a tuple.

Maybe the compiler applies courtesy conversions???
http://www.aldor.org/docs/HTML/chap7.html

If (**) is a tuple, then what is its type? Since we want it to be a 
tuple, it must be

   Tuple SOMETHING

. Well, now we have a problem to get SOMETHING from Integer and String.
Union(Integer, String) would work. But that looks totally ugly and would 
allow (4, 4711) instead of (4, "a").

Now the only thing that comes to my mind would be to use Cross instead 
of Tuple. But writing

extend Cross(T: Tuple Type): with {...} == add {...}

instead of

M(T: Tuple Type): with {...} == add {...}

and then

   import from Cross(Integer, String).

gives the same problems.

Ralf

---BEGIN aaa.as
#include "aldor"
#include "aldorio"

M(T: Tuple Type): with {
     m: T -> %;
     get: % -> T;
} == add {
     m(x:T):% == (x) pretend %;
     get(x:%):T == x pretend T;
}

main(): () == {
	import from Integer, String, Boolean;
	import from M(Integer, String);
	import from M(String, String, Boolean);
	a := m(4, "a");
	b := m("x", "y", true);
	--
	-- type error:
	--c := m(1, "x", false)
	--
	(x, y) := get(a);
	stdout << "(x,y) = (" << x << "," << y << ")" << newline;

	(i,j,k) := get(b);
	stdout << "(i,j,k) = (" << i << "," << j << "," << k << ")" << newline;
}
main();
---END aaa.as


From ralf at hemmecke.de  Sun Jul  8 17:19:32 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Sun, 08 Jul 2007 23:19:32 +0200
Subject: [Aldor-l] Unions in Aldor
In-Reply-To: <87bqemitv3.fsf@lattice.localdomain>
References: <87bqemitv3.fsf@lattice.localdomain>
Message-ID: <469154E4.9070504@hemmecke.de>

Hello,

the Aldor User Guide does not say anything about untagged unions.

Can

   Union(Integer, String)

be used in any reasonable way?

Ralf


From ralf at hemmecke.de  Mon Jul  9 12:26:43 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Mon, 09 Jul 2007 18:26:43 +0200
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
Message-ID: <469261C3.2050409@hemmecke.de>

> So really in Aldor when writes
> 
>  Union(x:Integer, y:String)
> 
> one is using the same conventions. So as Waldek implied, the fact that
> Aldor currently does not allow
> 
>  Union(Integer, String)
> 
> is not really a syntactic issue but rather a semantic one.

Unfortunately, the Aldor mailing list is dead. --- No replies to my 
recent question.

http://www.aldor.org/pipermail/aldor-l/2007-July/000643.html

Anyway, I would not say that Aldor does not allow 
"Union(Integer,String)". No hint in the AUG, but look at the error 
message given in
http://lists.nongnu.org/archive/html/axiom-developer/2007-07/msg00181.html

If you rewrite this program to

     U == Union(machInt: MachineInteger, sStr: String);

(just change this line) and then look at the error message.

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(machInt: Type)
       -- Enumeration(sStr: Type)

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.

Anyway, that usage of MachineInteger is not specified in the AUG so 
maybe one better does not use it that way.

Ralf


From bill.page at newsynthesis.org  Mon Jul  9 12:38:25 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Mon, 9 Jul 2007 12:38:25 -0400
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <469261C3.2050409@hemmecke.de>
References: <871wfigwg0.fsf@lattice.localdomain>
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
	<469261C3.2050409@hemmecke.de>
Message-ID: <fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>

On 7/9/07, Ralf Hemmecke <ralf at hemmecke.de> wrote:
> ...
> Anyway, I would not say that Aldor does not allow
> "Union(Integer,String)". No hint in the AUG, but look at the error
> message given in
> http://lists.nongnu.org/archive/html/axiom-developer/2007-07/msg00181.html
>
> If you rewrite this program to
>
>      U == Union(machInt: MachineInteger, sStr: String);
>
> (just change this line) and then look at the error message.
>
> 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(machInt: Type)
>        -- Enumeration(sStr: Type)
>
> 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?

> Anyway, that usage of MachineInteger is not specified in the AUG so
> maybe one better does not use it that way.
>

I have become quite confident that Aldor takes the most general road
whenever possible inspite of what might or might not be written in the
user's guide, so I am inclined to think that you are right.
'Union(Integer,String)' might very well be acceptible to the Aldor
compiler, we just need to intuit the proper usage.

Regards,
Bill Page.


From bill.page at newsynthesis.org  Mon Jul  9 13:29:56 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Mon, 9 Jul 2007 13:29:56 -0400
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
	<469261C3.2050409@hemmecke.de>
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
Message-ID: <fbcd16d40707091029m100d6bcw5ee85ce5f0e35691@mail.gmail.com>

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 at 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


From ralf at hemmecke.de  Mon Jul  9 14:08:48 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Mon, 09 Jul 2007 20:08:48 +0200
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>	
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>	
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>	
	<469261C3.2050409@hemmecke.de>
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
Message-ID: <469279B0.30203@hemmecke.de>

>> 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?

I should have told that I, of course, had already considered that option.

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(
                  with
                     ==  add ()
   ....
     Expected one of:
       -- Enumeration(machInt: Type)
       -- Enumeration(sStr: Type)

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.

>> Anyway, that usage of MachineInteger is not specified in the AUG so
>> maybe one better does not use it that way.

> I have become quite confident that Aldor takes the most general road
> whenever possible inspite of what might or might not be written in the
> user's guide, so I am inclined to think that you are right.
> 'Union(Integer,String)' might very well be acceptible to the Aldor
> compiler, we just need to intuit the proper usage.

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)

%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


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!


From bill.page at newsynthesis.org  Mon Jul  9 14:57:19 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Mon, 9 Jul 2007 14:57:19 -0400
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <469279B0.30203@hemmecke.de>
References: <871wfigwg0.fsf@lattice.localdomain>
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
	<469261C3.2050409@hemmecke.de>
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
	<469279B0.30203@hemmecke.de>
Message-ID: <fbcd16d40707091157k19352e96q9333943c74bd884@mail.gmail.com>

On 7/9/07, Ralf Hemmecke <ralf at hemmecke.de> 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/SandBoxAldorTesting#msg20070709122631-0500 at wiki.axiom-developer.org

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.


From ralf at hemmecke.de  Mon Jul  9 15:30:04 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Mon, 09 Jul 2007 21:30:04 +0200
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707091157k19352e96q9333943c74bd884@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>	
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>	
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>	
	<469261C3.2050409@hemmecke.de>	
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>	
	<469279B0.30203@hemmecke.de>
	<fbcd16d40707091157k19352e96q9333943c74bd884@mail.gmail.com>
Message-ID: <46928CBC.2050900@hemmecke.de>

Hi Bill,

> MachineInteger$'MachineInteger'

You are better than me. ;-) I tried

import from 'MachineInteger'
MachineInteger@'MachineInteger'

and failed. Using $ did not occur to me.

>> woodpecker:~/scratch>aldor -laldor -fx aaa.as
>> Compiler bug...Bug: gen0UnionCaseIndex: branch not in union
>>
>> Cool!

> Cool?

Well, you know how I meant it. But what can we do with a closed source 
compiler that has no developers? Finding bug after bug is just a waste 
of time. :-(

Ralf


From ralf at hemmecke.de  Fri Jul 13 07:57:16 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Fri, 13 Jul 2007 13:57:16 +0200
Subject: [Aldor-l] rep, per, Rep in SPAD/Aldor
In-Reply-To: <Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
References: <87bqemitv3.fsf@lattice.localdomain> <46915756.7010300@hemmecke.de>
	<87vecuh8cl.fsf@lattice.localdomain>
	<fbcd16d40707081850k4bd8adb2p4672976e39057dc2@mail.gmail.com>
	<87myy33x6c.fsf@soliton.cs.tamu.edu>
	<fbcd16d40707111337y431f4a6kb956df68a6aa93d9@mail.gmail.com>
	<Pine.LNX.4.64.0707111542050.26519@gauss.cs.tamu.edu>
	<46964339.54F23EC8@sci.ccny.cuny.edu>
	<87ejjd9v75.fsf@lattice.localdomain> <46971AF9.4030103@hemmecke.de>
	<87tzs893r2.fsf@lattice.localdomain>
	<87ps2w935x.fsf@lattice.localdomain>
	<87sl7sr8tt.fsf@soliton.cs.tamu.edu> <4697489D.9080403@hemmecke.de>
	<Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
Message-ID: <4697689C.40507@hemmecke.de>

On 07/13/2007 12:15 PM, Gabriel Dos Reis wrote:
> On Fri, 13 Jul 2007, Ralf Hemmecke wrote:
> 
> | rep, per, Rep are *not* part of the Aldor language. (Gaby, I know that you
> | know.)  Although, all this macro business is a bit hard to understand, I would
> | not really agree to add rep, per, and Rep to the language specification. The
> | "pretend" is enough. I would only say that they should become part of the
> | language if "pretend" disappears. but then we trade one construct for three.
> | And maybe "pretend" cannot be made superfluous.
> 
> I don't suggest that "pretend" be removed.  Just like general casts in C, or
> similar constructs in other languages, I don't think it should be
> removed and yet make Spad (or Aldor) expressive enough.  

OK.

> However, I do believe that `rep' and `per' are fundamentally part
> of the language semantics of domain.

Oh. You explicitly say "domain" (you don't include "package"). So I 
somehow have to agree. But not really. You know that by using "pretend", 
I could remove any uses of Rep, per, rep. Of course, nobody should write 
that code but rather follow the convention with Rep. What you want is to 
turn a convention into a rule. All I want to say is that this conflicts 
a bit with the design goals of Aldor: rather remove restrictions than 
introducing new features. I actually thought that you adhere to this 
principle. ;-)

> I don't think Rep should be there.
> Rep is quite of redundant with the pair rep/per.

I don't think, that I understand. There must be some way to actually 
write down the representation domain. If you have only rep and per, how 
would you do this?

> `rep' and `per' are there to fold/unfold views -- they are at the core
> of Spad or Aldor.

As I said, in some way you are right. It always confused me with this 
"Rep :=" or "Rep ==>" or "Rep ==" and no proper description of why Rep 
is so important (the concept, not the literal "Rep"). But now I know 
that if in my include file I define

macro {
	ying x == ((x)@%) pretend Ying;
	yang r == ((r)@Ying) pretend %;
}

I could completely do without Rep and rather say

---BEGIN aaa.as
#include "aldor"
#include "aldorio"

Foo: with {
   inj: Integer -> %;
   get: % -> Integer;
} == add {
   Ying == Integer;
   import from Ying;
   inj(z: Integer): % == yang z;
   get(x: %): Integer == ying x;
}
---END aaa.as

Gaby, I think that code is rather for others than for you. I am sure you 
understand that business quite well.

> | Why am I saying this? Maybe Martin now starts to listen more carefully... ;-)
> | 
> | In Aldor-Combinat, our species export two functions (simplified)
> | 
> |   structures: Set L -> Generator %;
> |   isoTypes:   Set L -> Generator %;
> | 
> | where L is the domain of labels of the structure.
> | 
> | I have not really a full picture yet (so don't take that overly serious), but
> | sometimes it comes to Martin's and my mind that isotypes should actually
> | return something else. For example, take Partition. structures, would return
> | set partitions while isoTypes (currently) return representatives of an
> | equivalence classes (a.k.a. isomorphism type). Clearly these equivalence
> | classes are in one-to-one correspondence with integer partitions. Integer
> | partitions could be handled much more efficiently. So it would be useful to
> | have 2 different representations for one domain.

> Yes.  How would that conflict with making rep and per part of the language?

No conflict. It just introduces new and unnecessary keywords. The 
conflict is with the principle I stated above.

> Many (most?) domains have only on representation, so it makes sense
> to `optimize' the notation for the common cases.

I completely agree. I just say it is not necessary to add new keywords. 
What do you think is the problem with rep and per as macros?

 > For those that do
> need more refinement, users can provide their own views and the language
> will recognize that.  There is a precedence for that.  In C++ for example,
> user-defined types come equipped with a compiler generated copy constructor
> if user the user does not declare one.  For many value types, that is
> exactly what is needed and the semantics is optimal.

I somehow begin to understand your view.

> So, think about this:
> 
>   (1) if a domain defines Rep, then automatically rep/per are
>      generated.

But that is also the way it is now in Aldor. If you don't define Rep and 
use rep/per, that gives a compile time error.

>   (2) if a domain defines one of per or rep, then the automatic
>       definition of the other is suppressed.

This is something I don't understand. Without defining Rep, I cannot 
define per. Why should I define rep/per anyway. They should just allow a 
different view on a object.

> | Let me for a moment even use an additional symbol %2. I'd like to say
> | 
> |   isoTypes: Set L -> Generator %2;
> | 
> | Of course that doesn't work in Aldor, but to my current knowledge it seems
> | that having several of these % symbols would better fit to the
> | multisort-algebra view on domains. It is not always the case that just one
> | carrier set is the most important and called %.

> I sort of agree.  When you have seveval representations (algebra in universal
> algebra sense) that abstract to the a given domain, then you actually
> have a category (in CT sense).  Would it not be convenient to express
> that in the code and actually use Spad categories?

OK, let me give my view on domains.

You have probably read
http://portal.axiom-developer.org/refs/articles/doye-aldor-phd.pdf
where Doye says that domains are somehow like order sorted algebras.

This is something like A = ((C1,...,Cn), (f1,...,fm)) with cardinal 
numbers n and m. (Of course, in Aldor we cannote express the infinite 
case since that would mean to write an infinite program.)

The order-sorted view is somehow correct, but if we look at an Aldor 
domain, there is always some distinguished thing (I don't know how to 
actually call this thing) which is denoted by %. It actually corresponds 
to the A from above. However, Aldor let's you think that it corresponds 
to C1 (the distinguished domain) which is usually denoted by Rep.

In Aldor we write

Foo: with {
   coerce: Integer -> %;
   test?: % -> Boolean;
} == add {
   Rep == String;
   ...
}

and mean something like

   Foo = ((%, Integer, Boolean), (coerce, test?))

in the multisorted algebra sense. We don't actually make Integer and 
Boolean (not String) an argument to Foo or "with", they are implicit.

Now, I have written % in the Foo = ... above and not

   Foo = ((Rep, Integer, Boolean), (coerce, test?))

since then the signatures of coerce and test? would not be OK.

That is the confusing point. Actually, there should be Rep and Foo 
should correspond to %. This is what we do in mathematics all the time. 
We speak of the (additive) monoid of integers and denote it by Z 
although that is at most the carrier set and some people would find that 
confusing if Z is used without reference to the additive structure.


I think there is a difference if we consider the "with" or the "add" 
part of a domain.

For the "with" part (and that is what a user of the domain actually 
sees), the above definition clearly corresponds to

   Foo = ((%, Integer, Boolean), (coerce, test?))

And for the user of this algebra, Foo and % are identified. That is what 
Aldor does here. (Although, it is mathematically not strictly correct.)
But most mathematicians do so in (almost) all cases.

Now let us look to the "add" part. There we have yet another domain, 
namely Rep. Inside "add" we actually consider an algebra like

   Foo' = ((%, Rep, Integer, Boolean), (coerce, test?, per, rep))

Hmmm, I have just cooked that all up right now, but it seems a pretty
coherent view on domains.

Since "add {...}" is an anonymous domain, it should actually export what 
is in the signature part of Foo', so let's see.

aldor -gloop
%1 >> #include "aldor"
%2 >> #include "aldorinterp"
%3 >> add {Rep==String;coerce(z:Integer):%==per 
"int";test?(x:%):Boolean==true}
   () @  with
         Rep: ? == String
         coerce: (z: AldorInteger) -> %
         test?: (x: %) -> Boolean

That is pretty close, but lacks per and rep. Gaby, I think that is one 
point for you. Here I would like to see rep,per, Rep. Don't you agree?
But note if we export Rep, we somehow are in conflict with "hiding the 
representation".

Any other opinions.

Actually, I started that mail with something else in mind, but now I am 
not so sure anymore whether I would really like to have %, %2, %3, etc. 
anymore. This correspondence of Foo with % is in some way rather 
ingenious. I have to think more about my original reference to wanting 
two representations for species in Aldor-Combinat.

Sorry, Gaby, I have not really responded to that categorial view in your 
statement above. I think I don't understand it properly. Could you 
elaborate and add a bit of your wisdom.

Thank you
Ralf


From ralf at hemmecke.de  Sat Jul 14 03:16:45 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Sat, 14 Jul 2007 09:16:45 +0200
Subject: [Aldor-l] rep, per, Rep in SPAD/Aldor
In-Reply-To: <Pine.LNX.4.64.0707132304530.11111@gauss.cs.tamu.edu>
References: <87bqemitv3.fsf@lattice.localdomain> <46915756.7010300@hemmecke.de>
	<87vecuh8cl.fsf@lattice.localdomain>
	<fbcd16d40707081850k4bd8adb2p4672976e39057dc2@mail.gmail.com>
	<87myy33x6c.fsf@soliton.cs.tamu.edu>
	<fbcd16d40707111337y431f4a6kb956df68a6aa93d9@mail.gmail.com>
	<Pine.LNX.4.64.0707111542050.26519@gauss.cs.tamu.edu>
	<46964339.54F23EC8@sci.ccny.cuny.edu>
	<87ejjd9v75.fsf@lattice.localdomain> <46971AF9.4030103@hemmecke.de>
	<87tzs893r2.fsf@lattice.localdomain>
	<87ps2w935x.fsf@lattice.localdomain>
	<87sl7sr8tt.fsf@soliton.cs.tamu.edu> <4697489D.9080403@hemmecke.de>
	<Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
	<4697689C.40507@hemmecke.de>
	<Pine.LNX.4.64.0707132304530.11111@gauss.cs.tamu.edu>
Message-ID: <4698785D.1000607@hemmecke.de>

Gaby,

just a short reply. As I said, I agree that Rep is an important issue. 
It would actually be good to hear what Stephen Watt has to say about 
that issue. I'd like to learn about the original intentions.

> Secondly, what we want to convey with `rep' is not that one can take 
> object foo, restrict its interpretation at type T and then do an 
> `on faith interpretation of its sequence of bytes representation as 
> an object at type U'.   Rather, what we want to say is that object foo 
> at type T is the result of a (hopefully injective) mapping from U and we 
> are interested in its pre-image.  

I don't know that I understand that paragraph. If I understand that 
correctly, then (U = Rep, T = %)

per: Rep -> %     injective map
   In general we have card(Rep)>=card(%). (If this would not always be
   true then I don't know.)

rep: % -> Rep     the "inverse" of per
   If x is from % then rep(x) should be an element from Rep such that
   per(rep x) = x. Since there might be several such elements, rep should
   choose one, and since we want rep to be a function, it should always
   choose the same element from the preimage of per.

Gaby, what you were saying is that Rep and % (in an abstract setting) 
need not be represented by the same string of bytes in memory. That is 
my interpretation of your paragraph. Abstractly seen, this seems to be 
OK, but from an efficiency point of view, it is probably always good if 
rep and per actually do nothing than changing the view on the same 
string of bytes in memory. But, I agree, that decision should be left to 
the compiler.

Ralf



From tmgisi at gmx.at  Sat Jul 14 03:41:53 2007
From: tmgisi at gmx.at (Christian Aistleitner)
Date: Sat, 14 Jul 2007 09:41:53 +0200
Subject: [Aldor-l] rep, per, Rep in SPAD/Aldor
In-Reply-To: <4697689C.40507@hemmecke.de>
References: <87bqemitv3.fsf@lattice.localdomain> <46915756.7010300@hemmecke.de>
	<87vecuh8cl.fsf@lattice.localdomain>
	<fbcd16d40707081850k4bd8adb2p4672976e39057dc2@mail.gmail.com>
	<87myy33x6c.fsf@soliton.cs.tamu.edu>
	<fbcd16d40707111337y431f4a6kb956df68a6aa93d9@mail.gmail.com>
	<Pine.LNX.4.64.0707111542050.26519@gauss.cs.tamu.edu>
	<46964339.54F23EC8@sci.ccny.cuny.edu>
	<87ejjd9v75.fsf@lattice.localdomain> <46971AF9.4030103@hemmecke.de>
	<87tzs893r2.fsf@lattice.localdomain>
	<87ps2w935x.fsf@lattice.localdomain>
	<87sl7sr8tt.fsf@soliton.cs.tamu.edu> <4697489D.9080403@hemmecke.de>
	<Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
	<4697689C.40507@hemmecke.de>
Message-ID: <op.tvf2b31gu6j4vy@spencer.aistleitner.info>

Hello,

On Fri, 13 Jul 2007 13:57:16 +0200, Ralf Hemmecke <ralf at hemmecke.de> wrote:

> In Aldor we write
>
> Foo: with {
>    coerce: Integer -> %;
>    test?: % -> Boolean;
> } == add {
>    Rep == String;
>    ...
> }
>
> and mean something like
>
>    Foo = ((%, Integer, Boolean), (coerce, test?))
>
> in the multisorted algebra sense. We don't actually make Integer and
> Boolean (not String) an argument to Foo or "with", they are implicit.

I understand why String is not an (implicit) Parameter of the with part.
I am rather convinced that it's not of importance, but why isn't String an  
implicit parameter of Foo (which is made up of the with _and_ the add  
part)?

> Now let us look to the "add" part. There we have yet another domain,
> namely Rep. Inside "add" we actually consider an algebra like
>
>    Foo' = ((%, Rep, Integer, Boolean), (coerce, test?, per, rep))
>
> Hmmm, I have just cooked that all up right now, but it seems a pretty
> coherent view on domains.

I am not too sure whether I can follow you here.
I assume you want us to assume "per" and "rep" occur in the code you gave  
for Foo some lines above.

Then by just looking at the syntax, I'd have to agree.
However, languages allowing macros typically act in two stages. One of  
which is macro expansion/replacement.
In Aldor this is somehow hidden from the user--in languages like C, it is  
more vivid.

Before macro expansion, I'd roughly agree with your signatures. But after  
macro expansion, I'd expect to get

     Foo' = ((%, Rep, Integer, Boolean), (coerce, test?))

. And that is just what you get when using the interactive loop:

> aldor -gloop
> %1 >> #include "aldor"
> %2 >> #include "aldorinterp"
> %3 >> add {Rep==String;coerce(z:Integer):%==per
> "int";test?(x:%):Boolean==true}
>    () @  with
>          Rep: ? == String
>          coerce: (z: AldorInteger) -> %
>          test?: (x: %) -> Boolean

No sign of rep and per, as the interpreter has expanded the macros for you.
rep and per are not functions to me. They are rewrite rules. IMHO, they  
(and the other macros) act on a meta level, when looking at the Aldor  
language.

> That is pretty close, but lacks per and rep. Gaby, I think that is one
> point for you. Here I would like to see rep,per, Rep. Don't you agree?

I do not agree.

> But note if we export Rep, we somehow are in conflict with "hiding the
> representation".

No we are not.
We are exporting a constant Rep.
But you are also exporting two other constants as well, namely coerce and  
test?.

Why should Rep be the representation of the domain and not coerce or test?  
?

Rep is nothing special. In your previous example you used Ying instead of  
Rep.
The export of Rep, Ying, or whatever does not tell "This domain uses this  
representation". It just tells you "This domains exports a Symbol with  
name Rep, Ying, or whatever".
A name is just a name.

Kind regards,
Christian



From bill.page at newsynthesis.org  Thu Jul  5 03:17:04 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Thu, 5 Jul 2007 03:17:04 -0400
Subject: [Aldor-l] [Axiom-developer] Problem kTuple wish 2.
In-Reply-To: <46810445.8010705@hemmecke.de>
References: <119483.36899.qm@web56712.mail.re3.yahoo.com>
	<87hcovybi7.fsf@lattice.localdomain>
	<9q4pkvd8nl.fsf@aquin.mat.univie.ac.at>
	<87d4zjyaor.fsf@lattice.localdomain>
	<9qsl8f449v.fsf@aquin.mat.univie.ac.at>
	<87wsxrw0pc.fsf@lattice.localdomain>
	<9q8xa7c90i.fsf@aquin.mat.univie.ac.at>
	<9q645b2dds.fsf@aquin.mat.univie.ac.at> <46810445.8010705@hemmecke.de>
Message-ID: <fbcd16d40707050017x7f7e7579yd2c976c898f72ef@mail.gmail.com>

On 6/26/07, Ralf Hemmecke wrote:
> ...
> Suppose you want a constructor like
>
> M(T: Tuple Cat): MCat(T) == add {...}
>
> for some given category Cat (For simplicity, lets say
>
>    define Cat: Category == with {=:(%,%)->Boolean}
>
> . The question now is how do I define MCat and the corresponding add
> {...} in such a way that I am able to generate an element of M in a
> simple form.
> ...

I tried to see how far I could get with this problem in Aldor. The
result is shown at:

http://wiki.axiom-developer.org/SandBoxAldorTuples

The code compiles and is apparently type correct but it does not
exactly produce the expected output. This code seems to work best
compiled to Lisp and iinked into Axiom. When I try the same thing with
the Aldor stand alone compiler I get some peculiar and unexpected
error messages. Perhaps this is pushing the limits of what the
compiler can do but I seems to be almost there... Perhaps a bug report
is in order?

Regards,
Bill Page.


From ralf at hemmecke.de  Thu Jul  5 06:03:18 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Thu, 05 Jul 2007 12:03:18 +0200
Subject: [Aldor-l] [Axiom-developer] Problem kTuple wish 2.
In-Reply-To: <fbcd16d40707050017x7f7e7579yd2c976c898f72ef@mail.gmail.com>
References: <119483.36899.qm@web56712.mail.re3.yahoo.com>	
	<87hcovybi7.fsf@lattice.localdomain>	
	<9q4pkvd8nl.fsf@aquin.mat.univie.ac.at>	
	<87d4zjyaor.fsf@lattice.localdomain>	
	<9qsl8f449v.fsf@aquin.mat.univie.ac.at>	
	<87wsxrw0pc.fsf@lattice.localdomain>	
	<9q8xa7c90i.fsf@aquin.mat.univie.ac.at>	
	<9q645b2dds.fsf@aquin.mat.univie.ac.at>
	<46810445.8010705@hemmecke.de>
	<fbcd16d40707050017x7f7e7579yd2c976c898f72ef@mail.gmail.com>
Message-ID: <468CC1E6.7010409@hemmecke.de>

> http://wiki.axiom-developer.org/SandBoxAldorTuples

Thank you, Bill. I think, I love the idea with

   get: % -> T

But that is only a tiny bit and actually does not solve the problem that 
  I finally would like to return something like

(F Integer, F String)

for some domain constructor F if the input T is (Integer,String).

> The code compiles and is apparently type correct but it does not
> exactly produce the expected output. This code seems to work best
> compiled to Lisp and iinked into Axiom. When I try the same thing with
> the Aldor stand alone compiler I get some peculiar and unexpected
> error messages. Perhaps this is pushing the limits of what the
> compiler can do but I seems to be almost there... Perhaps a bug report
> is in order?

To make that error message clearer I realized to following:

woodpecker:~/scratch>aldor -fx -laldor aaa.as
woodpecker:~/scratch>aaa
Looking in M((AldorInteger, String)) for m with code 111396431
Unhandled Exception: RuntimeError()
Export not found

for the program given below. To me that looks like a compiler bug.

To be honest, I am not sure whether the compiler should actually compile 
that code without complaint.

If one writes

   m(4, "a)                             (*)

then what is

   (4, "a")                             (**)

? A multi-value. But m cannot be applied to multivalues. It needs a tuple.

Maybe the compiler applies courtesy conversions???
http://www.aldor.org/docs/HTML/chap7.html

If (**) is a tuple, then what is its type? Since we want it to be a 
tuple, it must be

   Tuple SOMETHING

. Well, now we have a problem to get SOMETHING from Integer and String.
Union(Integer, String) would work. But that looks totally ugly and would 
allow (4, 4711) instead of (4, "a").

Now the only thing that comes to my mind would be to use Cross instead 
of Tuple. But writing

extend Cross(T: Tuple Type): with {...} == add {...}

instead of

M(T: Tuple Type): with {...} == add {...}

and then

   import from Cross(Integer, String).

gives the same problems.

Ralf

---BEGIN aaa.as
#include "aldor"
#include "aldorio"

M(T: Tuple Type): with {
     m: T -> %;
     get: % -> T;
} == add {
     m(x:T):% == (x) pretend %;
     get(x:%):T == x pretend T;
}

main(): () == {
	import from Integer, String, Boolean;
	import from M(Integer, String);
	import from M(String, String, Boolean);
	a := m(4, "a");
	b := m("x", "y", true);
	--
	-- type error:
	--c := m(1, "x", false)
	--
	(x, y) := get(a);
	stdout << "(x,y) = (" << x << "," << y << ")" << newline;

	(i,j,k) := get(b);
	stdout << "(i,j,k) = (" << i << "," << j << "," << k << ")" << newline;
}
main();
---END aaa.as


From ralf at hemmecke.de  Sun Jul  8 17:19:32 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Sun, 08 Jul 2007 23:19:32 +0200
Subject: [Aldor-l] Unions in Aldor
In-Reply-To: <87bqemitv3.fsf@lattice.localdomain>
References: <87bqemitv3.fsf@lattice.localdomain>
Message-ID: <469154E4.9070504@hemmecke.de>

Hello,

the Aldor User Guide does not say anything about untagged unions.

Can

   Union(Integer, String)

be used in any reasonable way?

Ralf


From ralf at hemmecke.de  Mon Jul  9 12:26:43 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Mon, 09 Jul 2007 18:26:43 +0200
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
Message-ID: <469261C3.2050409@hemmecke.de>

> So really in Aldor when writes
> 
>  Union(x:Integer, y:String)
> 
> one is using the same conventions. So as Waldek implied, the fact that
> Aldor currently does not allow
> 
>  Union(Integer, String)
> 
> is not really a syntactic issue but rather a semantic one.

Unfortunately, the Aldor mailing list is dead. --- No replies to my 
recent question.

http://www.aldor.org/pipermail/aldor-l/2007-July/000643.html

Anyway, I would not say that Aldor does not allow 
"Union(Integer,String)". No hint in the AUG, but look at the error 
message given in
http://lists.nongnu.org/archive/html/axiom-developer/2007-07/msg00181.html

If you rewrite this program to

     U == Union(machInt: MachineInteger, sStr: String);

(just change this line) and then look at the error message.

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(machInt: Type)
       -- Enumeration(sStr: Type)

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.

Anyway, that usage of MachineInteger is not specified in the AUG so 
maybe one better does not use it that way.

Ralf


From bill.page at newsynthesis.org  Mon Jul  9 12:38:25 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Mon, 9 Jul 2007 12:38:25 -0400
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <469261C3.2050409@hemmecke.de>
References: <871wfigwg0.fsf@lattice.localdomain>
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
	<469261C3.2050409@hemmecke.de>
Message-ID: <fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>

On 7/9/07, Ralf Hemmecke <ralf at hemmecke.de> wrote:
> ...
> Anyway, I would not say that Aldor does not allow
> "Union(Integer,String)". No hint in the AUG, but look at the error
> message given in
> http://lists.nongnu.org/archive/html/axiom-developer/2007-07/msg00181.html
>
> If you rewrite this program to
>
>      U == Union(machInt: MachineInteger, sStr: String);
>
> (just change this line) and then look at the error message.
>
> 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(machInt: Type)
>        -- Enumeration(sStr: Type)
>
> 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?

> Anyway, that usage of MachineInteger is not specified in the AUG so
> maybe one better does not use it that way.
>

I have become quite confident that Aldor takes the most general road
whenever possible inspite of what might or might not be written in the
user's guide, so I am inclined to think that you are right.
'Union(Integer,String)' might very well be acceptible to the Aldor
compiler, we just need to intuit the proper usage.

Regards,
Bill Page.


From bill.page at newsynthesis.org  Mon Jul  9 13:29:56 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Mon, 9 Jul 2007 13:29:56 -0400
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
	<469261C3.2050409@hemmecke.de>
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
Message-ID: <fbcd16d40707091029m100d6bcw5ee85ce5f0e35691@mail.gmail.com>

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 at 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


From ralf at hemmecke.de  Mon Jul  9 14:08:48 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Mon, 09 Jul 2007 20:08:48 +0200
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>	
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>	
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>	
	<469261C3.2050409@hemmecke.de>
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
Message-ID: <469279B0.30203@hemmecke.de>

>> 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?

I should have told that I, of course, had already considered that option.

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(
                  with
                     ==  add ()
   ....
     Expected one of:
       -- Enumeration(machInt: Type)
       -- Enumeration(sStr: Type)

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.

>> Anyway, that usage of MachineInteger is not specified in the AUG so
>> maybe one better does not use it that way.

> I have become quite confident that Aldor takes the most general road
> whenever possible inspite of what might or might not be written in the
> user's guide, so I am inclined to think that you are right.
> 'Union(Integer,String)' might very well be acceptible to the Aldor
> compiler, we just need to intuit the proper usage.

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)

%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


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!


From bill.page at newsynthesis.org  Mon Jul  9 14:57:19 2007
From: bill.page at newsynthesis.org (Bill Page)
Date: Mon, 9 Jul 2007 14:57:19 -0400
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <469279B0.30203@hemmecke.de>
References: <871wfigwg0.fsf@lattice.localdomain>
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>
	<469261C3.2050409@hemmecke.de>
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>
	<469279B0.30203@hemmecke.de>
Message-ID: <fbcd16d40707091157k19352e96q9333943c74bd884@mail.gmail.com>

On 7/9/07, Ralf Hemmecke <ralf at hemmecke.de> 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/SandBoxAldorTesting#msg20070709122631-0500 at wiki.axiom-developer.org

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.


From ralf at hemmecke.de  Mon Jul  9 15:30:04 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Mon, 09 Jul 2007 21:30:04 +0200
Subject: [Aldor-l] [Axiom-developer] Unions in Spad
In-Reply-To: <fbcd16d40707091157k19352e96q9333943c74bd884@mail.gmail.com>
References: <871wfigwg0.fsf@lattice.localdomain>	
	<E1I7rbo-0004GD-00@hera.math.uni.wroc.pl>	
	<fbcd16d40707090900y3b0a4270maad7686a15f4959b@mail.gmail.com>	
	<469261C3.2050409@hemmecke.de>	
	<fbcd16d40707090938u777c8f7ep7bc6aa730ba1ab5@mail.gmail.com>	
	<469279B0.30203@hemmecke.de>
	<fbcd16d40707091157k19352e96q9333943c74bd884@mail.gmail.com>
Message-ID: <46928CBC.2050900@hemmecke.de>

Hi Bill,

> MachineInteger$'MachineInteger'

You are better than me. ;-) I tried

import from 'MachineInteger'
MachineInteger@'MachineInteger'

and failed. Using $ did not occur to me.

>> woodpecker:~/scratch>aldor -laldor -fx aaa.as
>> Compiler bug...Bug: gen0UnionCaseIndex: branch not in union
>>
>> Cool!

> Cool?

Well, you know how I meant it. But what can we do with a closed source 
compiler that has no developers? Finding bug after bug is just a waste 
of time. :-(

Ralf


From ralf at hemmecke.de  Fri Jul 13 07:57:16 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Fri, 13 Jul 2007 13:57:16 +0200
Subject: [Aldor-l] rep, per, Rep in SPAD/Aldor
In-Reply-To: <Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
References: <87bqemitv3.fsf@lattice.localdomain> <46915756.7010300@hemmecke.de>
	<87vecuh8cl.fsf@lattice.localdomain>
	<fbcd16d40707081850k4bd8adb2p4672976e39057dc2@mail.gmail.com>
	<87myy33x6c.fsf@soliton.cs.tamu.edu>
	<fbcd16d40707111337y431f4a6kb956df68a6aa93d9@mail.gmail.com>
	<Pine.LNX.4.64.0707111542050.26519@gauss.cs.tamu.edu>
	<46964339.54F23EC8@sci.ccny.cuny.edu>
	<87ejjd9v75.fsf@lattice.localdomain> <46971AF9.4030103@hemmecke.de>
	<87tzs893r2.fsf@lattice.localdomain>
	<87ps2w935x.fsf@lattice.localdomain>
	<87sl7sr8tt.fsf@soliton.cs.tamu.edu> <4697489D.9080403@hemmecke.de>
	<Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
Message-ID: <4697689C.40507@hemmecke.de>

On 07/13/2007 12:15 PM, Gabriel Dos Reis wrote:
> On Fri, 13 Jul 2007, Ralf Hemmecke wrote:
> 
> | rep, per, Rep are *not* part of the Aldor language. (Gaby, I know that you
> | know.)  Although, all this macro business is a bit hard to understand, I would
> | not really agree to add rep, per, and Rep to the language specification. The
> | "pretend" is enough. I would only say that they should become part of the
> | language if "pretend" disappears. but then we trade one construct for three.
> | And maybe "pretend" cannot be made superfluous.
> 
> I don't suggest that "pretend" be removed.  Just like general casts in C, or
> similar constructs in other languages, I don't think it should be
> removed and yet make Spad (or Aldor) expressive enough.  

OK.

> However, I do believe that `rep' and `per' are fundamentally part
> of the language semantics of domain.

Oh. You explicitly say "domain" (you don't include "package"). So I 
somehow have to agree. But not really. You know that by using "pretend", 
I could remove any uses of Rep, per, rep. Of course, nobody should write 
that code but rather follow the convention with Rep. What you want is to 
turn a convention into a rule. All I want to say is that this conflicts 
a bit with the design goals of Aldor: rather remove restrictions than 
introducing new features. I actually thought that you adhere to this 
principle. ;-)

> I don't think Rep should be there.
> Rep is quite of redundant with the pair rep/per.

I don't think, that I understand. There must be some way to actually 
write down the representation domain. If you have only rep and per, how 
would you do this?

> `rep' and `per' are there to fold/unfold views -- they are at the core
> of Spad or Aldor.

As I said, in some way you are right. It always confused me with this 
"Rep :=" or "Rep ==>" or "Rep ==" and no proper description of why Rep 
is so important (the concept, not the literal "Rep"). But now I know 
that if in my include file I define

macro {
	ying x == ((x)@%) pretend Ying;
	yang r == ((r)@Ying) pretend %;
}

I could completely do without Rep and rather say

---BEGIN aaa.as
#include "aldor"
#include "aldorio"

Foo: with {
   inj: Integer -> %;
   get: % -> Integer;
} == add {
   Ying == Integer;
   import from Ying;
   inj(z: Integer): % == yang z;
   get(x: %): Integer == ying x;
}
---END aaa.as

Gaby, I think that code is rather for others than for you. I am sure you 
understand that business quite well.

> | Why am I saying this? Maybe Martin now starts to listen more carefully... ;-)
> | 
> | In Aldor-Combinat, our species export two functions (simplified)
> | 
> |   structures: Set L -> Generator %;
> |   isoTypes:   Set L -> Generator %;
> | 
> | where L is the domain of labels of the structure.
> | 
> | I have not really a full picture yet (so don't take that overly serious), but
> | sometimes it comes to Martin's and my mind that isotypes should actually
> | return something else. For example, take Partition. structures, would return
> | set partitions while isoTypes (currently) return representatives of an
> | equivalence classes (a.k.a. isomorphism type). Clearly these equivalence
> | classes are in one-to-one correspondence with integer partitions. Integer
> | partitions could be handled much more efficiently. So it would be useful to
> | have 2 different representations for one domain.

> Yes.  How would that conflict with making rep and per part of the language?

No conflict. It just introduces new and unnecessary keywords. The 
conflict is with the principle I stated above.

> Many (most?) domains have only on representation, so it makes sense
> to `optimize' the notation for the common cases.

I completely agree. I just say it is not necessary to add new keywords. 
What do you think is the problem with rep and per as macros?

 > For those that do
> need more refinement, users can provide their own views and the language
> will recognize that.  There is a precedence for that.  In C++ for example,
> user-defined types come equipped with a compiler generated copy constructor
> if user the user does not declare one.  For many value types, that is
> exactly what is needed and the semantics is optimal.

I somehow begin to understand your view.

> So, think about this:
> 
>   (1) if a domain defines Rep, then automatically rep/per are
>      generated.

But that is also the way it is now in Aldor. If you don't define Rep and 
use rep/per, that gives a compile time error.

>   (2) if a domain defines one of per or rep, then the automatic
>       definition of the other is suppressed.

This is something I don't understand. Without defining Rep, I cannot 
define per. Why should I define rep/per anyway. They should just allow a 
different view on a object.

> | Let me for a moment even use an additional symbol %2. I'd like to say
> | 
> |   isoTypes: Set L -> Generator %2;
> | 
> | Of course that doesn't work in Aldor, but to my current knowledge it seems
> | that having several of these % symbols would better fit to the
> | multisort-algebra view on domains. It is not always the case that just one
> | carrier set is the most important and called %.

> I sort of agree.  When you have seveval representations (algebra in universal
> algebra sense) that abstract to the a given domain, then you actually
> have a category (in CT sense).  Would it not be convenient to express
> that in the code and actually use Spad categories?

OK, let me give my view on domains.

You have probably read
http://portal.axiom-developer.org/refs/articles/doye-aldor-phd.pdf
where Doye says that domains are somehow like order sorted algebras.

This is something like A = ((C1,...,Cn), (f1,...,fm)) with cardinal 
numbers n and m. (Of course, in Aldor we cannote express the infinite 
case since that would mean to write an infinite program.)

The order-sorted view is somehow correct, but if we look at an Aldor 
domain, there is always some distinguished thing (I don't know how to 
actually call this thing) which is denoted by %. It actually corresponds 
to the A from above. However, Aldor let's you think that it corresponds 
to C1 (the distinguished domain) which is usually denoted by Rep.

In Aldor we write

Foo: with {
   coerce: Integer -> %;
   test?: % -> Boolean;
} == add {
   Rep == String;
   ...
}

and mean something like

   Foo = ((%, Integer, Boolean), (coerce, test?))

in the multisorted algebra sense. We don't actually make Integer and 
Boolean (not String) an argument to Foo or "with", they are implicit.

Now, I have written % in the Foo = ... above and not

   Foo = ((Rep, Integer, Boolean), (coerce, test?))

since then the signatures of coerce and test? would not be OK.

That is the confusing point. Actually, there should be Rep and Foo 
should correspond to %. This is what we do in mathematics all the time. 
We speak of the (additive) monoid of integers and denote it by Z 
although that is at most the carrier set and some people would find that 
confusing if Z is used without reference to the additive structure.


I think there is a difference if we consider the "with" or the "add" 
part of a domain.

For the "with" part (and that is what a user of the domain actually 
sees), the above definition clearly corresponds to

   Foo = ((%, Integer, Boolean), (coerce, test?))

And for the user of this algebra, Foo and % are identified. That is what 
Aldor does here. (Although, it is mathematically not strictly correct.)
But most mathematicians do so in (almost) all cases.

Now let us look to the "add" part. There we have yet another domain, 
namely Rep. Inside "add" we actually consider an algebra like

   Foo' = ((%, Rep, Integer, Boolean), (coerce, test?, per, rep))

Hmmm, I have just cooked that all up right now, but it seems a pretty
coherent view on domains.

Since "add {...}" is an anonymous domain, it should actually export what 
is in the signature part of Foo', so let's see.

aldor -gloop
%1 >> #include "aldor"
%2 >> #include "aldorinterp"
%3 >> add {Rep==String;coerce(z:Integer):%==per 
"int";test?(x:%):Boolean==true}
   () @  with
         Rep: ? == String
         coerce: (z: AldorInteger) -> %
         test?: (x: %) -> Boolean

That is pretty close, but lacks per and rep. Gaby, I think that is one 
point for you. Here I would like to see rep,per, Rep. Don't you agree?
But note if we export Rep, we somehow are in conflict with "hiding the 
representation".

Any other opinions.

Actually, I started that mail with something else in mind, but now I am 
not so sure anymore whether I would really like to have %, %2, %3, etc. 
anymore. This correspondence of Foo with % is in some way rather 
ingenious. I have to think more about my original reference to wanting 
two representations for species in Aldor-Combinat.

Sorry, Gaby, I have not really responded to that categorial view in your 
statement above. I think I don't understand it properly. Could you 
elaborate and add a bit of your wisdom.

Thank you
Ralf


From ralf at hemmecke.de  Sat Jul 14 03:16:45 2007
From: ralf at hemmecke.de (Ralf Hemmecke)
Date: Sat, 14 Jul 2007 09:16:45 +0200
Subject: [Aldor-l] rep, per, Rep in SPAD/Aldor
In-Reply-To: <Pine.LNX.4.64.0707132304530.11111@gauss.cs.tamu.edu>
References: <87bqemitv3.fsf@lattice.localdomain> <46915756.7010300@hemmecke.de>
	<87vecuh8cl.fsf@lattice.localdomain>
	<fbcd16d40707081850k4bd8adb2p4672976e39057dc2@mail.gmail.com>
	<87myy33x6c.fsf@soliton.cs.tamu.edu>
	<fbcd16d40707111337y431f4a6kb956df68a6aa93d9@mail.gmail.com>
	<Pine.LNX.4.64.0707111542050.26519@gauss.cs.tamu.edu>
	<46964339.54F23EC8@sci.ccny.cuny.edu>
	<87ejjd9v75.fsf@lattice.localdomain> <46971AF9.4030103@hemmecke.de>
	<87tzs893r2.fsf@lattice.localdomain>
	<87ps2w935x.fsf@lattice.localdomain>
	<87sl7sr8tt.fsf@soliton.cs.tamu.edu> <4697489D.9080403@hemmecke.de>
	<Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
	<4697689C.40507@hemmecke.de>
	<Pine.LNX.4.64.0707132304530.11111@gauss.cs.tamu.edu>
Message-ID: <4698785D.1000607@hemmecke.de>

Gaby,

just a short reply. As I said, I agree that Rep is an important issue. 
It would actually be good to hear what Stephen Watt has to say about 
that issue. I'd like to learn about the original intentions.

> Secondly, what we want to convey with `rep' is not that one can take 
> object foo, restrict its interpretation at type T and then do an 
> `on faith interpretation of its sequence of bytes representation as 
> an object at type U'.   Rather, what we want to say is that object foo 
> at type T is the result of a (hopefully injective) mapping from U and we 
> are interested in its pre-image.  

I don't know that I understand that paragraph. If I understand that 
correctly, then (U = Rep, T = %)

per: Rep -> %     injective map
   In general we have card(Rep)>=card(%). (If this would not always be
   true then I don't know.)

rep: % -> Rep     the "inverse" of per
   If x is from % then rep(x) should be an element from Rep such that
   per(rep x) = x. Since there might be several such elements, rep should
   choose one, and since we want rep to be a function, it should always
   choose the same element from the preimage of per.

Gaby, what you were saying is that Rep and % (in an abstract setting) 
need not be represented by the same string of bytes in memory. That is 
my interpretation of your paragraph. Abstractly seen, this seems to be 
OK, but from an efficiency point of view, it is probably always good if 
rep and per actually do nothing than changing the view on the same 
string of bytes in memory. But, I agree, that decision should be left to 
the compiler.

Ralf



From tmgisi at gmx.at  Sat Jul 14 03:41:53 2007
From: tmgisi at gmx.at (Christian Aistleitner)
Date: Sat, 14 Jul 2007 09:41:53 +0200
Subject: [Aldor-l] rep, per, Rep in SPAD/Aldor
In-Reply-To: <4697689C.40507@hemmecke.de>
References: <87bqemitv3.fsf@lattice.localdomain> <46915756.7010300@hemmecke.de>
	<87vecuh8cl.fsf@lattice.localdomain>
	<fbcd16d40707081850k4bd8adb2p4672976e39057dc2@mail.gmail.com>
	<87myy33x6c.fsf@soliton.cs.tamu.edu>
	<fbcd16d40707111337y431f4a6kb956df68a6aa93d9@mail.gmail.com>
	<Pine.LNX.4.64.0707111542050.26519@gauss.cs.tamu.edu>
	<46964339.54F23EC8@sci.ccny.cuny.edu>
	<87ejjd9v75.fsf@lattice.localdomain> <46971AF9.4030103@hemmecke.de>
	<87tzs893r2.fsf@lattice.localdomain>
	<87ps2w935x.fsf@lattice.localdomain>
	<87sl7sr8tt.fsf@soliton.cs.tamu.edu> <4697489D.9080403@hemmecke.de>
	<Pine.LNX.4.64.0707130455200.8511@gauss.cs.tamu.edu>
	<4697689C.40507@hemmecke.de>
Message-ID: <op.tvf2b31gu6j4vy@spencer.aistleitner.info>

Hello,

On Fri, 13 Jul 2007 13:57:16 +0200, Ralf Hemmecke <ralf at hemmecke.de> wrote:

> In Aldor we write
>
> Foo: with {
>    coerce: Integer -> %;
>    test?: % -> Boolean;
> } == add {
>    Rep == String;
>    ...
> }
>
> and mean something like
>
>    Foo = ((%, Integer, Boolean), (coerce, test?))
>
> in the multisorted algebra sense. We don't actually make Integer and
> Boolean (not String) an argument to Foo or "with", they are implicit.

I understand why String is not an (implicit) Parameter of the with part.
I am rather convinced that it's not of importance, but why isn't String an  
implicit parameter of Foo (which is made up of the with _and_ the add  
part)?

> Now let us look to the "add" part. There we have yet another domain,
> namely Rep. Inside "add" we actually consider an algebra like
>
>    Foo' = ((%, Rep, Integer, Boolean), (coerce, test?, per, rep))
>
> Hmmm, I have just cooked that all up right now, but it seems a pretty
> coherent view on domains.

I am not too sure whether I can follow you here.
I assume you want us to assume "per" and "rep" occur in the code you gave  
for Foo some lines above.

Then by just looking at the syntax, I'd have to agree.
However, languages allowing macros typically act in two stages. One of  
which is macro expansion/replacement.
In Aldor this is somehow hidden from the user--in languages like C, it is  
more vivid.

Before macro expansion, I'd roughly agree with your signatures. But after  
macro expansion, I'd expect to get

     Foo' = ((%, Rep, Integer, Boolean), (coerce, test?))

. And that is just what you get when using the interactive loop:

> aldor -gloop
> %1 >> #include "aldor"
> %2 >> #include "aldorinterp"
> %3 >> add {Rep==String;coerce(z:Integer):%==per
> "int";test?(x:%):Boolean==true}
>    () @  with
>          Rep: ? == String
>          coerce: (z: AldorInteger) -> %
>          test?: (x: %) -> Boolean

No sign of rep and per, as the interpreter has expanded the macros for you.
rep and per are not functions to me. They are rewrite rules. IMHO, they  
(and the other macros) act on a meta level, when looking at the Aldor  
language.

> That is pretty close, but lacks per and rep. Gaby, I think that is one
> point for you. Here I would like to see rep,per, Rep. Don't you agree?

I do not agree.

> But note if we export Rep, we somehow are in conflict with "hiding the
> representation".

No we are not.
We are exporting a constant Rep.
But you are also exporting two other constants as well, namely coerce and  
test?.

Why should Rep be the representation of the domain and not coerce or test?  
?

Rep is nothing special. In your previous example you used Ying instead of  
Rep.
The export of Rep, Ying, or whatever does not tell "This domain uses this  
representation". It just tells you "This domains exports a Symbol with  
name Rep, Ying, or whatever".
A name is just a name.

Kind regards,
Christian



