From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 3D2BABC37 for ; Tue, 9 Feb 2010 23:32:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoMCAPNwcUvRVdzgkGdsb2JhbACDCZdVCBUBAQEBCQkMBxMDIK0MLgqBQIVRiHEBAQMFgSqCSlsEiy4 X-IronPort-AV: E=Sophos;i="4.49,438,1262559600"; d="scan'208";a="56562281" Received: from mail-fx0-f224.google.com ([209.85.220.224]) by mail4-smtp-sop.national.inria.fr with ESMTP; 09 Feb 2010 23:32:10 +0100 Received: by fxm24 with SMTP id 24so17237fxm.3 for ; Tue, 09 Feb 2010 14:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=5FFz02OBfodO/7EQMHjvcEp2SBFvsOEgIK72wlV3V8o=; b=Cxm4KJKTTSa4c3sHgsNYNHTimQVmJicUQJwsUCdqHINsZRMNoDzq7KeELd5KoYp7KY VqMjVU3jc/aeRGJlW+RWGr54tKswRCPd9aMR2fwrwFBlFe2Yzl7KnGpg+eNZiXatwZ6H wGZH/sdXvIeXUgt6TOnhys2xM5KDCZKZ9/5UM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=wZy0XPJEqgXStXj1MZlW9+07ikS99lsVEyefBLskyXfUZBJy0JDcGBN4hQk9OVAelw +WNj64mZyHipsiPDQBCJE6dsyu6aPGfeaL+h9MYUfkRI0RBQtU9skFPxPYN1D94dN5U+ Bzf7Gw1o2nZDsC9twQWqXItswZRvlUtzcB5rs= MIME-Version: 1.0 Received: by 10.239.193.80 with SMTP id h16mr800344hbi.55.1265754729133; Tue, 09 Feb 2010 14:32:09 -0800 (PST) Reply-To: saptarshi.guha@gmail.com In-Reply-To: <201002092333.39698.jon@ffconsultancy.com> References: <1e7471d51002091250of7a686fq537a03c9401c868f@mail.gmail.com> <201002092333.39698.jon@ffconsultancy.com> From: Saptarshi Guha Date: Tue, 9 Feb 2010 17:31:49 -0500 Message-ID: <1e7471d51002091431m6451a2b5p35718c57920e9071@mail.gmail.com> Subject: Re: [Caml-list] The need to specify 'rec' in a recursive function defintion To: Jon Harrop Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; recursive:01 defintion:01 recursive:01 recursion:01 frog:98 stack:01 caml-list:01 latter:03 let:03 let:03 overflow:03 tricky:04 simplifies:06 specify:06 namespace:07 Yes, I see that f isn't recursive, because it simplifies down to 2*(x+1) but for a reader(at least myself) it can be bit tricky to consume. My experience of reading the /definition/ of a function which includes a call to itself is that it is recursive. On the stackoverflow post, you mentioned that the British ML branch forces different names (since recursion is by default), and though it does pollute the namespace, personally I find it easier to read. Regards Saptarshi >> Wouldn't one of way of detecting a recursive function would be to see >> if the indeed the function calls itself? > > =C2=A0let f x =3D x + 1 > =C2=A0let f x =3D 2 * f x > > Is the latter "f" recursive or not? > > See my answer to the same question on stack overflow: > > http://stackoverflow.com/questions/900585/why-are-functions-in-ocaml-f-no= t-recursive-by-default/1891573 > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?e >