axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Re: [Aldor-l] exports and constants


From: Ralf Hemmecke
Subject: [Axiom-developer] Re: [Aldor-l] exports and constants
Date: Tue, 25 Jul 2006 00:50:33 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060516)


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




reply via email to

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