[Aldor-l] 'has' and 'with' and bug

Christian Aistleitner tmgisi at gmx.at
Tue Aug 21 02:55:46 EDT 2007


Hello Ralf,

On Tue, 21 Aug 2007 05:40:19 +0200, <hemmecke at risc.uni-linz.ac.at> wrote:

>>   #include "aldor"
>>   import from String, TextWriter, Character;
>>
>>   Dom: with {
>>   } == add {
>>     privateFunc(): () == {}
>>   }
>>
>>   main(): () == {
>>     stdout << "Dom has 'privateFunc' ? " <<
>>       (Dom has with {privateFunc: ()->()}) <<
>>       newline;
>>   }
>>   main();
>>
>> You've been curious, why the result of this code is "T".
>
>> The reason is that "Dom" has static type "with {}" and dynamic type
>> "with {privateFunc: () -> ()}".
>
> Stephen, could you say a final word here. Is that a bug or it "T" really
> the right answer?

Until Stephen answers, let me take a final try to convince you.

>> In
>>
>>   A: B == C add D
>>
>> , A is of static type B. The type of "C add D" is A's dynamic type.
>
> The type of A is always B no matter whether you say it's "dynamic"
> or static.

Let me give you another counter-example.

   #include "algebra"
   import from String, TextWriter, Character;

   f( R: Ring ):() == {
     stdout << "R has Field " <<
       (R has Field) <<
       newline;
   }

   f( (Fraction Integer add)@Field );

I hope you now agree that the constant "R" within the function call is  
equivalent to

   R: Ring == Fraction Integer add;

(In my previous example
http://www.aldor.org/pipermail/aldor-l/2007-August/000672.html
you claimed that the difference is that the parameter does not bear an  
"add". In this example we now have an "add". )
(The superfluous "@ Field" is just to help Aldor determine which  
categories (not functions) the type of the "add" expression should have.  
Without it, it does not compile, as an "add" expression likes to take a  
look at the left-hand side of "==" to determine which categories (not  
functions) its type should have, and there is no "==" here.)

In any case, the (static) type of "R" is "Ring", as determined by the  
parameter's definition "R: Ring".

If what you said about "A: B == C add D" would be true,
"R" (A) would be of type "Ring" (B) no matter whether I say it's "dynamic"  
or "static".
Hence, "R has Field" should give false in any case, according to what you  
presented

However, the result is T:
____________________________________________
tmgisi at spencer
cwd: ~/aldor
./demo
R has Field T

But I suppose, you are still not convinced ...

Kind regards,
Christian

P.S.: Can you provide any code or passages in the AUG to underpin your  
claims or give counter-examples to my point of view?




More information about the Aldor-l mailing list