Version franÁaise
Home ††† About ††† Download ††† Resources ††† Contact us †††

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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
<> 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:
> Archives:
> Beginner's list:
> Bug reports: