Hi Diego.

I think one of the best reason to *not* have let rec as the default is
shadowing.

Say you have a function that expect a string as an argument

let foo s =
  ....
  ....

and you realize that it's the job of the callee and not the caller to
check that the string is escaped. You can just change it to:

let foo s =
  let s = escape s in
  ....
  ....

And before you say "let's just do this for function and not for other
values", let's remember that nothing separate a function from a value
syntactically (it's a functional language, a function *is* a value),
only typing can. And you can't type your program before you know its
structure, and let vs let rec is part of the structure.

Then on top of that we can add that it makes compilation faster,
optimization easier, and code clearer (and, of course, backward
compatibility :))!

Cheers

Alexandre


On Mon, Jan 2, 2012 at 5:37 PM, Diego Olivier Fernandez Pons
<[email protected]> wrote:
>     List,
>
> I was wondering if there was any reason not to make "let rec" the default /
> sole option, meaning cases where you clearly don't want a "let rec" instead
> of "let" (only in functions, not cyclic data).
>
>          Diego Olivier


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to