[Aldor-l] Special casing...
Martin Rubey
martin.rubey at univie.ac.at
Tue Feb 20 08:55:12 EST 2007
"Christian Aistleitner" <tmgisi at gmx.at> writes:
> Hello,
>
> > 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.
>
> without further machinery, I'll doubt that this is possible. And I strongly
> disadvise you to use such a design.
Yes, I think you are right. If a new SPAD or Aldor would support this, it would
imply quite an overhead, since it would only make sense if one could "extend" f
after having it compiled into a library...
Very likely, it is better to implement a (domain valued) function that could be
used roughly as follows:
SpecialCasesForFDictionary: List Record(a: S, t: T)
f(a: S): T == lookupSpecialCases(a, { generic implementation })
Martin
More information about the Aldor-l
mailing list