Mon, 11 Sep 2000 08:51:52 +0100, Chris Angus <[EMAIL PROTECTED]> pisze:

> > Some people think that the monomorphism restriction should be removed.
> > (There are no technical problems with this AFAIK.)
> 
> I was under the impression that this introduced to increase efficency 
> (prevents the same expression being multiply evaluated in certain
> circumstances)

It's easy to detect when a value is used monomorphically and compile
it to an updatable closure in this case. (When used polymorphically,
it would be incorrect with the restriction anyway.)

There are subtle cases when removing the restiction turns a correct
program into an incorrect one:
    let x = read "5" in (x :: Int, show x)
With the restriction x is monomorphic and the first usage disambiguates
the second. Without the restriction it's ambiguous. IMHO this is rare;
more often the restriction itself gets in the way.

The remaining difference is when a top level value is exported.
With the restriction, it's either instantiated by usages, or defaulted
to a numeric type, or ambiguous. Without the restriction the compiler
cannot tell how it will be used in other modules and must compile it
polymorphically (unless it produces two copies).

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK


Reply via email to