From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=MISSING_HEADERS,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 7AE45BC6B for ; Sun, 11 Nov 2007 01:44:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKbeNUfAXQImh2dsb2JhbACPAgEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,400,1188770400"; d="scan'208";a="5663417" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Nov 2007 01:44:47 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lAB0ikSp026873 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 11 Nov 2007 01:44:46 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKbeNUdIDtbli2dsb2JhbACPAgEBAQgEBAkKEQU X-IronPort-AV: E=Sophos;i="4.21,400,1188770400"; d="scan'208";a="4106262" Received: from hu-out-0506.google.com ([72.14.214.229]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Nov 2007 01:44:46 +0100 Received: by hu-out-0506.google.com with SMTP id 16so2329290hue for ; Sat, 10 Nov 2007 16:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=HzH0SQZsEQrLMeqNuRYYLkmmNnualsn6r5jhJ4sx1jQ=; b=VrX1omPma9J6yhJKUO84j3Dt7KtdDbhiahkk7iqag2kFg9gSVuXnZPhdqd3DKrGF5EcINlGTpj3odZwXsP3SyPQGL/qdnD5231EwAwu3gkZ23IDVr467M2L04HqDHObUDM6EhpICFoODNa4sjOf5cKBXvX2zyj1INs4vTRRzz38= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=FBIELYnXtXqPCYzuIy9Xz9ucG4nRpG52cdy2zhhBJvr2lGK0qQ0J4eVln20MlK3PMLt1FFZ5jemCltRaL7kWZzJKJwyjQex5DoYKgfeMioIYii5oENtHx0zrSMvKgZ62YbWgZC6KQMH3auDH+a/souAl1wWd2/fhaqKYsPaWYfo= Received: by 10.86.100.7 with SMTP id x7mr2920255fgb.1194741885642; Sat, 10 Nov 2007 16:44:45 -0800 (PST) Received: from ?192.168.0.5? ( [87.88.165.197]) by mx.google.com with ESMTPS id j9sm7440950mue.2007.11.10.16.44.43 (version=SSLv3 cipher=RC4-MD5); Sat, 10 Nov 2007 16:44:44 -0800 (PST) Message-ID: <47365084.9080305@lix.polytechnique.fr> Date: Sun, 11 Nov 2007 01:44:52 +0100 From: Arnaud Spiwack User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 Cc: Caml List Subject: Re: [Caml-list] cost to let rec? References: <71767b800711091320h5d14afb8qc614fb4f1951ed06@mail.gmail.com> <4735E76A.908@fmf.uni-lj.si> In-Reply-To: <4735E76A.908@fmf.uni-lj.si> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit Sender: Arnaud Spiwack X-Miltered: at discorde with ID 4736507E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lix:01 redefinition:01 rec':01 andrej:01 andrej:01 beginner's:01 ocaml:01 bug:01 beginners:01 wrote:01 arnaud:01 arnaud:01 rec:01 rec:01 compile:01 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 > >