[Aldor-l] Special casing...
Martin Rubey
martin.rubey at univie.ac.at
Fri Feb 16 16:58:16 EST 2007
Dear Christian, Dear Gaby,
do you think that something like (i.e., achieving the same or a similar effect
as) the following is possible in Aldor (or in improved SPAD):
I'd like the compiler to allow something like
---------------------------------------------------------------------------
f(a: S): T == { generic implementation }
f(specialValueOfTypeS): T == { special implementation for specialValueOfTypeS }
f(otherSpecialValueOfTypeS): T == { special imp. for otherSpecialValueOfTypeS }
g(c: T, d: T): T == { ... f(c) ... f(d) ...}
---------------------------------------------------------------------------
So, if c happens to be specialValueOfTypeS, then the special implementation is
used, and so on.
As criterion for equality, identical memory location would be sufficient for
me. Of course, f should be allowed to be type-valued.
In the axiom interpreter, the above is allowed for ordinary functions, i.e.,
functions that return an element of a domain.
For example, one can define
f: Integer -> Integer
f 0 == 1
f 1 == 1
f n == f(n-1) + f(n-2)
I guess it is possible to define
f(a: S): T == {
if a = specialValueOfTypeS then
{ special implementation for specialValueOfTypeS }
else if a = otherSpecialValueOfTypeS then
{ special imp. for otherSpecialValueOfTypeS }
else { generic implementation }
}
but this would not really be very extensible...
Martin
More information about the Aldor-l
mailing list