English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
The need to specify 'rec' in a recursive function defintion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-02-09 (22:32)
From: Saptarshi Guha <saptarshi.guha@g...>
Subject: Re: [Caml-list] The need to specify 'rec' in a recursive function defintion
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.


>> Wouldn't one of way of detecting a recursive function would be to see
>> if the indeed the function calls itself?
>  let f x = x + 1
>  let f x = 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-not-recursive-by-default/1891573
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/?e