caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* The need to specify 'rec' in a recursive function defintion
@ 2010-02-09 20:50 Saptarshi Guha
  2010-02-09 21:55 ` [Caml-list] " Guillaume Yziquel
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Saptarshi Guha @ 2010-02-09 20:50 UTC (permalink / raw)
  To: caml-list

Hello,
 I was wondering why recursive functions need to be specified with
"rec". According to Practical Ocaml, to "inform the compiler that the function
exists". But when entering the function definition, can't the compiler note that
the function is being defined so that when it sees the function calling itself,
it wont say "Unbound value f"?

How is the knowledge of a function being rec taken advantage of (in
ocaml) as opposed to other languages
(leaving aside tail call optimization).

Wouldn't one of way of detecting a recursive function would be to see
if the indeed the function calls itself?

These are very much beginners' questions.
Thank you
Saptarshi


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-02-16 16:22 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-09 20:50 The need to specify 'rec' in a recursive function defintion Saptarshi Guha
2010-02-09 21:55 ` [Caml-list] " Guillaume Yziquel
2010-02-09 22:14   ` Saptarshi Guha
2010-02-09 22:01 ` Gerd Stolpmann
2010-02-09 21:58   ` Guillaume Yziquel
2010-02-09 22:34     ` Gerd Stolpmann
2010-02-10  0:07       ` Guillaume Yziquel
2010-02-10  3:10         ` Alain Frisch
2010-02-09 22:16   ` Saptarshi Guha
2010-02-09 23:29   ` Jon Harrop
2010-02-10 10:15     ` rossberg
2010-02-10  7:19   ` Andrej Bauer
2010-02-10  9:36     ` Francois Maurel
2010-02-10 10:12     ` rossberg
2010-02-09 23:33 ` Jon Harrop
2010-02-09 22:31   ` Saptarshi Guha
2010-02-10  0:12     ` Jon Harrop
2010-02-10 22:01 ` Stefan Monnier
2010-02-10 22:25   ` [Caml-list] " Till Varoquaux
2010-02-11  1:48     ` Jon Harrop
2010-02-15 15:46     ` Stefan Monnier
2010-02-15 17:33       ` [Caml-list] " Jon Harrop
2010-02-15 20:36         ` Stefan Monnier
2010-02-16 14:42           ` Stefan Monnier
2010-02-16 16:21             ` [Caml-list] " Ashish Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).