[Aldor-l] [Aldor-combinat-devel] parametric types and instantiation

Ralf Hemmecke ralf at hemmecke.de
Wed Oct 25 07:57:10 EDT 2006


> Furthermore, I guess you are mixing up concepts of parametrized types
> and  Aldor, at least conceptionally.

> In Aldor, there are no parametrized types or domains.

> Dom( Param ): ReturnType == add { ... }

> is effectively _not_ a parametrized domain Dom, but Dom is a
> constant. Dom  is a function (just like any other function, like
> add:( Integer, Integer ) -> Integer). However, the function Dom
> creates domains.

That sounds OK to me.

Array(MachineInteger) and Array(Integer) are two domains. Array itself 
is not a domain. It's a function that returns domains.
Now whether one calls "Array" also a "parametrized domain" is a matter 
of agreeing on some terminology.

> In OO, you instantiate Dom.In Aldor, you evaluate Dom.

But evaluating Dom at 1 and Dom at 2 creates (instantiates) two domains 
Dom(1) and Dom(2).

> In OO, instantiation of Dom always carries a (at least conceptional)
> connection to Dom.In Aldor the result of Dom( A ) is (hopefully)
> completely decoupled from  Dom and A, just as the result 7 of add( 3,
> 4 ) is completely decoupled   from add, 3, and 4.

I think, I cannot confirm that Dom(1) does not carry information about 
Dom and 1. Actually I don't know for domains, but for categories how 
would the following be possible then?

 >aldor -grun -laldor aaa.as
T
F
F
T

If CatA and DomA where really functions then the second line should give 
true since neither the DomA nor CatA actually depend on their parameter.

But the above result perfectly follow the AUG.

Ralf

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

define CatA(T: PrimitiveType): Category == with;
define CatB(T: PrimitiveType): Category == with;
DomA(T: PrimitiveType): CatA(T) == add;
DomB(T: PrimitiveType): CatB(T) == add;
stdout << (DomA(Integer) has CatA(Integer)) << newline;
stdout << (DomA(Integer) has CatA(String)) << newline;
stdout << (DomA(Integer) has CatB(Integer)) << newline;
stdout << (DomA(Integer) has with) << newline;
---END aaa.as



More information about the Aldor-l mailing list