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