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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 84A57BB81 for ; Sat, 1 Oct 2005 23:36:09 +0200 (CEST) Received: from web26808.mail.ukl.yahoo.com (web26808.mail.ukl.yahoo.com [217.146.176.84]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id j91La9gG009095 for ; Sat, 1 Oct 2005 23:36:09 +0200 Received: (qmail 88106 invoked by uid 60001); 1 Oct 2005 21:36:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ZCl6gBGVs0RtIFJnholT4epfV6EfIO1YBwLFI7lzQnV5jqMw+21LT/MmISaRZBfSoJCISqGygmZ14thbO0Ea6gmQ14o7U+Szpey+mJdKDJiHLTy7xhsTIQ36H7XjSm+QFhEzQprAl6b9I1Ht8P+Fr7lbKrv53gnfbiXYCmcsG68= ; Message-ID: <20051001213609.88104.qmail@web26808.mail.ukl.yahoo.com> Received: from [83.180.78.172] by web26808.mail.ukl.yahoo.com via HTTP; Sat, 01 Oct 2005 23:36:08 CEST Date: Sat, 1 Oct 2005 23:36:08 +0200 (CEST) From: Martin Chabr Subject: Ant: Re: Ant: Re: [Caml-list] Avoiding shared data To: Oliver Bandel Cc: caml-list@yquem.inria.fr In-Reply-To: <20050930225737.GA592@first.in-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 433F0149.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 avoiding:01 oliver:01 ocaml:01 runtime:01 recursive:01 recursive:01 ocaml:01 recursion:01 recursion:01 oliver:01 bandel:01 in-berlin:01 mutable:01 substituted:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.0.3 Hello Oliver, I am trying to find a programming style within the spectrum of possibilities which OCaml supports. This programming style should be easy to produce, easy to read and efficient in runtime. Sometimes a nested system of "for" or "while" loops appears simpler to me than a system of recursive calls. Sometimes such systems of recursive calls remind me of undisciplined goto jumps. There is an excellent OCaml tutorial at: http://www.ocaml-tutorial.org/. In this tutorial the author gives a simple example of a stack-blowing, non-tail-recursive code. The following tail-recursive version takes two functions instead of one and is relatively much more complex. In general, for the real world problems, it is much worse. I cite the author: "That was a brief overview of tail recursion, but in real world situations determining if a function is tail recursive can be quite hard." I believe him. This is at: http://www.ocaml-tutorial.org/if_statements,_loops_and_recursion section tail recursion. I think that some problems, like simple operations on lists, can be easier described by pattern matching and recursion, whereas for others it appears more natural to take loops. I also think that what looks simple or not depends on the person. I myself have spent half of my life with imperative languages. Regards, Martin --- Oliver Bandel wrote: > On Mon, Sep 26, 2005 at 11:07:30PM +0200, Martin > Chabr wrote: > > Hello William, > > > > I am using a mutable record. I am programming this > 90% > > in the imperative (non-functional) style, so that > I > > can rewrite critical parts into Fortran easily. > > Another reason is, I am an intermediate user and > > finding out whether the recursion is a tail-one or > not > > is difficult for me. > > When you 90% of your code are writing in imperative > style > and do not go deeper into the functional/recursive > world, you will never be able to distinguish between > tail-rec and non-tail-rec style. > > But: It is not really hard to find the distinction > betwen > the two styles, but often the explanations are not > made > well. > Sometimes it's only one or two words in an > explanation about > tail-rec/non-tail-rec that must be substituted by > other words, > and the distinction can be made visible very easy. > > On the other hand: writing mor funtional/recursive > code will > make you more used to to this... > > Ciao, > Oliver > > _______________________________________________ > 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 > ___________________________________________________________ Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx