Version française
Home     About     Download     Resources     Contact us    
Browse thread
cost to let rec?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Arnaud Spiwack <Arnaud.Spiwack@l...>
Subject: Re: [Caml-list] cost to let rec?
Yet another cost, but not too significant is redefinition.

Suppose you have a function "wrap" that does some safety stuff, on your 
argument "x". Well, then you want to name "warp x". One way of doing so 
is by hiding "x" so that you cannot access it :

let x = wrap x in ...

This does not work with "let rec" :

let rec x = wrap x in ...
"This kind of expression is not allowed as right-hand side of `let rec'"

Conclusion : "let rec" hides one variable from the scope of the body of 
the let, might be useful to have a "let" for these kind of things.


Arnaud Spiwack

Andrej Bauer a écrit :
> Ralph Douglass wrote:
>   
>> Is there any cost to defining a function with "let rec" instead of just
>> "let"?  A slightly longer compile time or something?  I'm just curious.
>>     
>
> The main cost of using "let rec" instead of "let" out of laziness or
> "convenience" is time spent debugging the resulting bugs and the extra
> time needed for software maintainance ("WTF did this Ralph guy write let
> rec everywhere? My god he's totally incompetent and I have to clean
> up."). This typically costs far, far more than any processor time you
> might gain.
>
> Source code is for humans.
>
> Andrej
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>