[Aldor-l] exports and constants
Ralf Hemmecke
ralf at hemmecke.de
Mon Jul 24 18:50:33 EDT 2006
>> Now let's make things a bit more complicated. Would you be able to guess
>> the output of the following program?
>>
>> ---BEGIN aaa7.as
>> #include "aldor"
>> #include "aldorio"
>>
>> define CatA: Category == with;
>> define CatX: Category == with;
>>
>> A: Join(CatX, CatA) == add;
>> X: CatX == A add; stdout << (X has CatA) << newline;
>> Y: CatX == A; stdout << (Y has CatA) << newline;
>> #if WITHZ
>> Z: CatA == Y; stdout << (Z has CatA) << newline;
>> #endif
>> ---END aaa7.as
>>
>> Right.
>>
>> >aldor -grun -laldor aaa7.as
>> F
>> T
>>
>> >aldor -DWITHZ -grun -laldor aaa7.as
>> "aaa7.as", line 11: Z: CatA == Y; stdout << (Z has CatA) << newline;
>> ...........^
>> [L11 C12] #1 (Error) There are 0 meanings for `Y' in this context.
>> The possible types were:
>> Y: CatX, a local
>> The context requires an expression of type CatA.
>>
>> So the compiler now thinks that the type of Y is just CatX. OK, but then
>> why can the program print "T" in the previous compilation?
> Because Y has static type CatX and dynamic type with{ CatA; CatX; }.
> The compiler uses the static type to check if Y can be used in "Z: CatA
> == Y".
OK. If the static type is used for type satisfactions, I can live with that.
> The "has" checks the dynamic type.
So "has" is in fact a weak way to reflect about domains. But surely, we
need true reflections.
Ralf
More information about the Aldor-l
mailing list