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-10 (22:25)
From: Till Varoquaux <till@p...>
Subject: Re: [Caml-list] Re: The need to specify 'rec' in a recursive function defintion
On Wed, Feb 10, 2010 at 5:01 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> Wouldn't one of way of detecting a recursive function would be to see
>> if the indeed the function calls itself?
> That's what Haskell does, yes.

Let's make things clear here: the "rec" *really* is a feature; it is
very convenient to reuse the same identifier to express something in
the process of being built (e.g. something going through a pipeline).

For instance:

let g () =
  let f s =
    if !debug then
       Printf.printf "f is called with value: %s\n%!" s
    f s

Some (including me) would even argue that it is sad that type
definitions don't use "rec".

>        Stefan
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs