<?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/39062037ea7b698ed4d0e8eac5722e3f"
  from="Marc de Falco &lt;marc.defalco@g...&gt;"
  author="Marc de Falco"
  date="2009-10-23T16:15:03"
  subject="Re: [Caml-list] forbidden construct as right hand side of &quot;let rec&quot;"
  prev="2009/10/9e2c94423f18872e0c1332c3f6115d66"
  next="2009/10/5b7e1adc784c98522967086aecba7d6c"
  prev-in-thread="2009/10/7ee1373a402f5409b88f6f1276dca2cd"
  next-in-thread="2009/10/7d3be716f3343f93c3c99f20ba3ddb6e"
  prev-thread="2009/10/61b3aa5e2d0ffb16d5dd3dca5a2afd9a"
  next-thread="2009/10/3bcd2f16c7ea93d30f4c2afe13184103"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Re: [Caml-list] forbidden construct as right hand side of &quot;let rec&quot;">
<msg 
  url="2009/10/7ee1373a402f5409b88f6f1276dca2cd"
  from="Damien Guichard &lt;alphablock@o...&gt;"
  author="Damien Guichard"
  date="2009-10-23T15:39:23"
  subject="Re: [Caml-list] forbidden construct as right hand side of &quot;let rec&quot;">
<msg 
  url="2009/10/39062037ea7b698ed4d0e8eac5722e3f"
  from="Marc de Falco &lt;marc.defalco@g...&gt;"
  author="Marc de Falco"
  date="2009-10-23T16:15:03"
  subject="Re: [Caml-list] forbidden construct as right hand side of &quot;let rec&quot;">
<msg 
  url="2009/10/7d3be716f3343f93c3c99f20ba3ddb6e"
  from="blue storm &lt;bluestorm.dylc@g...&gt;"
  author="blue storm"
  date="2009-10-23T17:51:09"
  subject="Re: [Caml-list] forbidden construct as right hand side of &quot;let rec&quot;">
</msg>
</msg>
</msg>
</thread>

<contents>
The issue is that this definition can't be generalized to lists of  
arbitrary size.
The code
let list_cycle l =
  let rec loop = l @ loop in
  loop
will not be accepted.

I don't know the exact rule, but I guess that on the right-hand side  
of a
let rec defining a ground value named foo you can only write a term  
which
evaluates to a finite ground term on the currently defined variables +  
foo.
That is to say something that evaluates to a finite tree of  
constructors with
constants or defined variables as leaves.
Maybe someone more knowledgeable could state the exact rule.

- marc

P.S. : the code using Obj is far from a solution as it modifies the  
existing structure
of the list to add cycling and thus, breaks persistency.

Le 23 oct. 2009 à 17:35, Damien Guichard a écrit :

&gt;
&gt; let list_cycle2 a b =
&gt;   let rec loop = a::b::loop
&gt;   in loop
&gt;
&gt;
&gt; - damien
&gt;
&gt; En réponse au message
&gt; de : Lukasz Stafiniak
&gt; du : 2009-10-23 01:10:37
&gt; À : caml-list
&gt; CC :
&gt; Sujet : Re: [Caml-list] forbidden construct as right hand side of  
&gt; "let rec"
&gt;
&gt; While we are at it, what is the best way to convert a "straight" list
&gt; into a cyclic list?
&gt;
&gt; i.e. convert
&gt;
&gt; let l = a::b::[]
&gt;
&gt; into
&gt;
&gt; let rec l = a::b::l
&gt;
&gt; (for arbitrary length lists). (The answer I recall from the archives
&gt; was using Obj.magic to mutate the [] in the original list).
&gt;
&gt; On Fri, Oct 23, 2009 at 12:34 AM, Stéphane Glondu  &lt;steph@glondu.net  
&gt; &gt; wrote:
&gt; &gt; Mathias Kende a écrit :
&gt; &gt; &gt;       let rec g = f g
&gt; &gt;
&gt; &gt; What about:
&gt; &gt;
&gt; &gt;  let rec g x = f g x
&gt;
&gt; _______________________________________________
&gt; Caml-list mailing list. Subscription management:
&gt; http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
&gt; Archives: http://caml.inria.fr
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs
&gt; _______________________________________________
&gt; Caml-list mailing list. Subscription management:
&gt; http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
&gt; Archives: http://caml.inria.fr
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs

</contents>

</message>

