[Top][All Lists]

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

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

From: Bill Page
Subject: [Axiom-developer] RE: [Aldor-l] exports and constants
Date: Mon, 24 Jul 2006 21:11:29 -0400


On July 24, 2006 5:57 PM you wrote:
> On 07/24/2006 08:12 PM, Bill Page wrote:
> > ... 
> > Hmmm... in Aldor values do not have types. "A add {...}" is
> > an "add expression".
> OK, maybe my formulation was a bit misleading. I agree that 
> if you look at the memory location where a value is stored
> Aldor does not store type information, but still the _compiler_
> should know about the type of that value. Same for "A add {...}".
> Of course that is a value since I can assign it to a constant
> (or maybe even to a variable--have not tried this), so the
> compiler should know its type.

I disagree. What we are talking about is "type inference" and such
inferences can depend on context.

> There are no things in Aldor without type.

Well, it might be better to say that "type" is not an intrinsic
property of a value or even of certain expressions (such as add
expressions), but rather that the type depends on the context.

> ... 
> ---BEGIN
> #include "aldor"
> #include "aldorio"
> define CatA: Category == with;
> define CatB: Category == with;
> define CatC: Category == with;
> define CatAB : Category == Join(CatA,  CatB);
> define CatABC: Category == Join(CatAB, CatC);
> ABC: CatABC == add;
> X: CatA ==  ABC     @CatAB;
> Y: CatA == (ABC add);
> Z: CatA == (ABC add)@CatAB;
> W: CatA == (ABC add)@CatABC;
> stdout << (X has CatABC) << newline;
> stdout << (Y has CatABC) << newline;
> stdout << (Z has CatABC) << newline;
> stdout << (W has CatABC) << newline;
> ---END
> I am sure you can guess the output of the above program.
> But in order to have it recorded in the mailing list, I give 
> the output 
> here.
>  >aldor -grun -laldor
> T
> F
> F
> T
> Please take some time to understand why for Y the answer is
> false but for Z it is true. Compare that to the output for X.
> Is the output for W clear?

The result for Z is false. Maybe you meant "why for Y the
answer is false but for X it is true"?

I think these results make sense if you think of @CatAB as providing
"hints" to Aldor's type inference process. This is described in some
detail here:

A First Report on the A# Compiler

It is false for Y because the "visibility rule" that I mentioned
earlier and which I claim is not so clear (I admit that it is not
sufficiently explicit.)

It is true for X because in spite of the hint @CatAB, the context
here is not an add expression.

And the output for W seems entirely satisfactory to me.

Bill Page.

reply via email to

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