From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 87CFF7EE48 for ; Mon, 2 Mar 2015 07:25:05 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jordojw@gmail.com) identity=pra; client-ip=209.85.215.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jordojw@gmail.com"; x-sender="jordojw@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of jordojw@gmail.com designates 209.85.215.48 as permitted sender) identity=mailfrom; client-ip=209.85.215.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jordojw@gmail.com"; x-sender="jordojw@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f48.google.com) identity=helo; client-ip=209.85.215.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jordojw@gmail.com"; x-sender="postmaster@mail-la0-f48.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BpAQDUAfRUlDDXVdFahDKDBsU5B00BAQEBAQEQAQEBAQcLCwkSMIQoER0BGx4DEhAPAiYCJAERAQUBIhsah3gBAxGsJIMrPjGLLoFrgneOIgoZJw1UhQUBBQ6BE5FOgUMFilyMaIF7gRoRjnGBdBIjgQwJgiUcgXEdMYJDAQEB X-IPAS-Result: A0BpAQDUAfRUlDDXVdFahDKDBsU5B00BAQEBAQEQAQEBAQcLCwkSMIQoER0BGx4DEhAPAiYCJAERAQUBIhsah3gBAxGsJIMrPjGLLoFrgneOIgoZJw1UhQUBBQ6BE5FOgUMFilyMaIF7gRoRjnGBdBIjgQwJgiUcgXEdMYJDAQEB X-IronPort-AV: E=Sophos;i="5.09,674,1418079600"; d="scan'208";a="101737359" Received: from mail-la0-f48.google.com ([209.85.215.48]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 02 Mar 2015 07:25:04 +0100 Received: by labgf13 with SMTP id gf13so3623551lab.5 for ; Sun, 01 Mar 2015 22:25:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=rsGzAJAgVcEltU1nP2apVUyVRQTj8wDL/a7UcNFeoi0=; b=fze6JQcfrIDwqmlSSKGGHo9PcE+xakQbD+W0fh1woz6c0OPcylAOoUYBLb032y7ZoC jxTPd6XsaGNmdrP231SUhtf+QQ9EJkG/6EohXj/DOEWbWQQUSFxqlu0lU2Z5cDVEUYI1 zcNF4ma8wE/HRi/K/VEAOhB5YIpGrAcTcMP1Lyy8Zn8Ji6Betmom5vCwt3vyvuhmNno2 NtDi980Ua+Kk4TYdtLZE3UFYX944EE394h7CaM56uwC6UYFPY7/fUHgEq+DXAzUYbPto KgwvqXfja5wshZHcPitQw2KQxZHWclNq/Zymjm5T55bpAkAbBFfdlnhLnkLqr6ZATfL2 cvyA== MIME-Version: 1.0 X-Received: by 10.152.182.196 with SMTP id eg4mr22717424lac.70.1425277504181; Sun, 01 Mar 2015 22:25:04 -0800 (PST) Received: by 10.25.128.3 with HTTP; Sun, 1 Mar 2015 22:25:04 -0800 (PST) Date: Sun, 1 Mar 2015 22:25:04 -0800 Message-ID: From: Jordan W To: "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 X-Validation-by: jordojw@gmail.com Subject: [Caml-list] Mutual recursion propagates individual recursion. Why? (Note: When trying any of these examples, make sure to kill/restart your top level between each examples - non-recursive bindings that should fail will appear to work because they use existing bindings in the environment). My understanding is that self-recursion in OCaml is introduced via the `let rec` binding keyword pair. let rec x a = x a A sequence of let bindings are made *both* mutually recursive, *and* individually self-recursive via a combination of `let rec` and the `and` keyword. (* Notice how y is made self recursive as well *) let rec x a = (x a + y a) and y a = (x a + y a);; The `and` keyword by itself is not sufficient to introduce mutual recursion, and not sufficient to introduce self-recursion for any of the bindings joined by the `and`. (* Does not work *) let x a = x a and y a = (x a + y a) (* Does not work *) let x a = y a and y a = x a My questions are: 1. Is there any effect to having the `and` keyword, without a `let rec` that initiates the let binding sequence? 2. Is there any way to introduce mutual recursion without also introducing self-recursion on *all* of the bindings? I would like self-recursion to be independent from mutual recursion. It would be nice to be able to create several mutually recursive bindings that are not individually self-recursive. I imagine the syntax to accomplish this would require each binding to be opened with "let" or "let rec" which would be totally reasonable. (* Three mutually recursive functions that are not self-recursive *) let rec thisOneIsSelfRecursive x = ... and let thisOneIsNotSelfRecursive y = ... and let rec thisOneIsAlsoSelfRecursive z = ...; This becomes more desirable when one of the mutually recursive bindings is a non-function value that you did not want to make self-recursive by accident (which causes cycles). Jordan