[Top][All Lists]

[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 (X11/20060516)

Now let's make things a bit more complicated. Would you be able to guess
the output of the following program?

#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;
Z: CatA == Y;      stdout << (Z has CatA) << newline;


 >aldor -grun -laldor

 >aldor -DWITHZ -grun -laldor
"", 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.


reply via email to

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