From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 91B2ABB9A for ; Fri, 28 Oct 2005 15:04:00 +0200 (CEST) Received: from mail.physik.uni-muenchen.de (mail.physik.uni-muenchen.de [192.54.42.129]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9SD3x8j003693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 28 Oct 2005 15:04:00 +0200 Received: from localhost (unknown [127.0.0.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id A040120011; Fri, 28 Oct 2005 15:03:59 +0200 (CEST) Received: from mail.physik.uni-muenchen.de ([127.0.0.1]) by localhost (mail.physik.uni-muenchen.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07837-01-44; Fri, 28 Oct 2005 15:03:59 +0200 (CEST) Received: from mailhost.cip.physik.uni-muenchen.de (kaiser.cip.physik.uni-muenchen.de [141.84.136.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 8627B20007; Fri, 28 Oct 2005 15:03:59 +0200 (CEST) Received: from eiger.cip.physik.uni-muenchen.de (eiger.cip.physik.uni-muenchen.de [141.84.136.54]) by mailhost.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 43AFD26E87; Fri, 28 Oct 2005 15:03:55 +0200 (CEST) Received: by eiger.cip.physik.uni-muenchen.de (Postfix, from userid 3092) id 32B6E12F75; Fri, 28 Oct 2005 15:03:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by eiger.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 28EEE12ECC; Fri, 28 Oct 2005 15:03:50 +0200 (CEST) Date: Fri, 28 Oct 2005 15:03:50 +0200 (CEST) From: Thomas Fischbacher To: Tato Thetza Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml efficiency/optimization? In-Reply-To: <1130494903.8339.246224558@webmail.messagingengine.com> Message-ID: References: <1130494903.8339.246224558@webmail.messagingengine.com> X-BOFH: Daemons did it MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: amavisd-new at physik.uni-muenchen.de X-Miltered: at nez-perce with ID 436221BF.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 ocaml:01 sicp:01 2005,:98 cip:98 cip:98 lambda:01 lambda:01 wrote:01 immutable:01 caml:02 debian:02 somewhere:02 functional:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_FAIL autolearn=disabled version=3.0.3 On Fri, 28 Oct 2005, Tato Thetza wrote: > I've been reading over > http://caml.inria.fr/pub/docs/manual-ocaml/index.html and have learned > two things: > -lists are immutable and singly linked, which explains why 1::[2;3] is > valid while [2,3]::1 is not, and why its efficient. > -the proper way to ensure tail-recursive optimization > > question: are these and other optimizations documented somewhere > officially? I find it a little uncomfortable I've been learning OCaml > without knowning such internal details. Any secrets I should definitely > know if I were to use this language in production? These are not really "OCaml internal details or optimizations", but rather ideas and techniques which have been around very long, and are relevant in virtually any (non-lazy) functional language. I think you might benefit from reading the one book most often used in courses on the subject: Abelson & Sussman's "Structure and Interpretation of Computer Programs". The complete text is available online at http://mitpress.mit.edu/sicp/ -- regards, tf@cip.physik.uni-muenchen.de (o_ Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\ (lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_ (if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)