Ralf Hemmecke wrote:
>
> That I consider a case where 'has' is useful.
>
> I actually wonder what will happen if I define two functions:
>
> mygcd(R: Field)(a: R, b: R): R == {
> if zero? a and zero? b then 0 else 1;
> }
> mygcd(R: EuclideanDomain)(a: R, b: R): R == {
> while not zero? b repeat { (a, b) := (b, a rem b) }
> return a;
> }
>
> and then try to say:
>
> Q ==> Fraction Integer;
> g: (Q, Q) -> Q := mygcd Q
>
> Should a compiler reject it or simply take the most specific code? Note,
> that the compiler already knows that 'Q has Field'.
>
> Even for Aldor I don't think there is a specification for that. (Can
> somebody prove me wrong?)
>
The code is bad for two reasons:
1) it is hard to check statically due to overloading on type argument
2) the overloading is ambigous
In current Spad the code is illegal because of 1 (Spad compiler
can not handle overloading on type arguments). I believe that
in Aldor it is illegal because of 2.
--
Waldek Hebisch
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---