On 15-Jul-1998, Mark P Jones <[EMAIL PROTECTED]> wrote:
> We've seen several examples now, from Ralf, Alex, and others, where it is
> useful to relax the proposed restriction:
>
> The types in an instance-declaration context must all be type variables.
...
> Without the restriction, it is easy to come up with examples that could
> lead to non-termination.
Is non-termination really a problem in practice?
A simple work-around is for the type checker to perform only
up to a certain number of iterations, and if that fails, to
report an error message, with the error message specifying
the compiler option that can be used to increase the iteration
limit.
The Mercury compiler uses this work-around to avoid the need to
enforce the monomorphism restriction (which exists for a similar reason,
to ensure termination of type inference). In practice, this seems to
work fine; people very rarely write type-correct programs that require
more that a few iterations to type check, so by setting the iteration
limit to a reasonably large number, the only programs it catches are
the occaisional type-incorrect program.
The only real drawback is that for a very few really complex programs,
the first compilation will fail, and users will need to recompile
with the iteration limit set higher. But this is not a major drawback.
Many existing systems have similar schemes, where you need to recompile
with a different option if you exceed some limit. For example, on many
OSs, when building very large shared libraries, you need to use `-fPIC'
instead of `-fpic'. Similarly, on the AMD29000, gcc requires that
source files which compile to more than 256k bytes be compiled with
`-mlarge'. And on RS/6000 and PowerPC, large programs (those with more
than 16384 different global variables or floating point constants) need
to be compiled with `-mminimal-toc'. On the MIPS, if the program is
bigger than 512M, it may need to be compiled with `-mlong-calls'. On
HPPA, very large shared libraries sometimes need to be compiled with
`-mmillicode-long-calls'. And so on. (I could go on, but I think those
examples are enough to make my point ;-)
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.