From: Arnaud Spiwack <Arnaud.Spiwack@lix.polytechnique.fr>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] cost to let rec?
Date: Sun, 11 Nov 2007 01:44:52 +0100 [thread overview]
Message-ID: <47365084.9080305@lix.polytechnique.fr> (raw)
In-Reply-To: <4735E76A.908@fmf.uni-lj.si>
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
>
>
prev parent reply other threads:[~2007-11-11 0:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 21:20 Ralph Douglass
2007-11-09 21:28 ` [Caml-list] " Till Varoquaux
2007-11-10 17:16 ` Andrej Bauer
2007-11-11 0:44 ` Arnaud Spiwack [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47365084.9080305@lix.polytechnique.fr \
--to=arnaud.spiwack@lix.polytechnique.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox