Version française
Home     About     Download     Resources     Contact us    
Browse thread
Avoiding shared data
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Chabr <martin_chabr@y...>
Subject: Ant: Re: Ant: Re: [Caml-list] Avoiding shared data
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 <oliver@first.in-berlin.de> 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