<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/10/11ac90cafeaac1ff5bfbc5c8bae87c55"
  from="Vincent Aravantinos &lt;vincent.aravantinos@g...&gt;"
  author="Vincent Aravantinos"
  date="2009-10-27T18:38:04"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants"
  prev="2009/10/fc32c1d24a699d0d3095b3a2ee159a8e"
  next="2009/10/2e5786ed1315ff7882444d8a62fec6ab"
  prev-in-thread="2009/10/fc32c1d24a699d0d3095b3a2ee159a8e"
  next-in-thread="2009/10/2e5786ed1315ff7882444d8a62fec6ab"
  prev-thread="2009/10/cb62aba28e1f84b31e18b738aad34fde"
  next-thread="2009/10/a542f981ec63f1fb137050f0370eebab"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="A strange typing error with polymorphic variants">
<msg 
  url="2009/10/cbdd8317941f2f2afc1923fe5247492e"
  from="Marc de Falco &lt;marc@d...&gt;"
  author="Marc de Falco"
  date="2009-10-27T10:28:26"
  subject="A strange typing error with polymorphic variants">
<msg 
  url="2009/10/fc32c1d24a699d0d3095b3a2ee159a8e"
  from="Jake Donham &lt;jake@d...&gt;"
  author="Jake Donham"
  date="2009-10-27T18:25:12"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants">
<msg 
  url="2009/10/11ac90cafeaac1ff5bfbc5c8bae87c55"
  from="Vincent Aravantinos &lt;vincent.aravantinos@g...&gt;"
  author="Vincent Aravantinos"
  date="2009-10-27T18:38:04"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants">
<msg 
  url="2009/10/2e5786ed1315ff7882444d8a62fec6ab"
  from="Vincent Aravantinos &lt;vincent.aravantinos@g...&gt;"
  author="Vincent Aravantinos"
  date="2009-10-27T19:02:25"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>

Le 27 oct. 09 à 19:24, Jake Donham a écrit :

&gt; On Tue, Oct 27, 2009 at 3:28 AM, Marc de Falco &lt;marc@de-falco.fr&gt;  
&gt; wrote:
&gt;&gt; The following code :
&gt;&gt; type 'a p = R of 'a t | E of float
&gt;&gt;     and 'a t = { mutable p : 'a p; c : 'a }
&gt;&gt; let f =
&gt;&gt;     let x = sqrt(2.0) in
&gt;&gt;     fun () -&gt; { c = `A; p = E 0.0 }
&gt;&gt;
&gt;&gt; generates the error :
&gt;&gt;   The type of this expression, unit -&gt; _[&gt; `A ] t,
&gt;&gt;   contains type variables that cannot be generalized
&gt;&gt;
&gt;&gt; but if I change the x definition to "let x = 2.0 in" then it works.
&gt;
&gt; I think this is just the value restriction. The type of f is
&gt; generalized only if the right hand side is a value (rather than an
&gt; expression needing some computation); in your examples the one that
&gt; fails is not a value, the others are. It looks like there is a
&gt; relaxation to allow let bindings which are themselves values.

With the -dlambda option, the "sqrt(2.0)" version gives:
   (let
     (f/92
        (let (x/93 (caml_sqrt_float 2.0))
          (function param/94 (makemutable 0 [1: 0.0] 65a))))

whereas the "2.0" version gives:
   (let (f/96 (let (x/97 2.0) (function param/98 (makemutable 0 [1:  
0.0] 65a))))

i.e. this last version is inlined.

I thought the yping was done before (??)

V.






</contents>

</message>

