Re: [Caml-list] The need to specify 'rec' in a recursive function defintion

2010-02-09 Thread Saptarshi Guha
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 tha

Re: [Caml-list] The need to specify 'rec' in a recursive function defintion

2010-02-09 Thread Saptarshi Guha
> > let f arg = expr > > is just a short-hand notation for > > let f = (fun arg -> expr) > > or, in other words, the anonymous function constructor (fun arg -> expr) > is the basic building block to which the "let" construction is broken > down. The anonymous function has a direct counterpart in th

Re: [Caml-list] The need to specify 'rec' in a recursive function defintion

2010-02-09 Thread Saptarshi Guha
Thanks, very helpful. >> let f = fun x -> x + 1 (1) >> >> let f x = f (f x) (2) This works in ocaml because, it replaces f (in (2) ) from that of (1). Which is why i need f previously defined. Correct me if i'm wrong. > >> Wouldn't one of way of detecting a recursive function would be to see

[Caml-list] The need to specify 'rec' in a recursive function defintion

2010-02-09 Thread Saptarshi Guha
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 c