English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] C style for loop
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-11 (13:12)
From: Bruce Hoult <bruce@h...>
Subject: Re: [Caml-list] C style for loop
At 2:47 PM +0200 11/10/01, Berke Durak wrote:
>On Thu, Oct 11, 2001 at 01:47:07AM -0400, Jeff Henrikson wrote:
>>  Okay, so maybe I should be more specific about what I want in a
>>  "C-style for loop."  Its readablity merits are hopefully self
>>  evident.  Well, unless you're a compulsive CPS addict who wishes
>>  even his grocery list could be written to tail recurse. . .
>Do you really pretend that ``C-style for loops'' have ``self-evident
>readability merits'' ?! My opinion is that ```C-style'' loop syntax
>IS unreadable, ununderstandable and unprovable. How many people using
>C know the _exact_ semantics of :
>	for(exp1;expr2;expr3){expr4}

Sure, it's easy:

      while (expr2){

It's damn ugly, though, and with much unnecessary repetition of the 
control variable in simple cases.

>I never manage to remember if expr3 is evaluated if expr2 is always

No.  See above.

>  However with
>	for i = 0 to 33 do
>		f i
>	done
>the ONLY little point about which you MIGHT hesitate is : does f 33
>get called or does the loop stop at 32 ?

Dylan makes has explicit versions:

   for (i from 0 to 33)

   for (i from 0 below 33)

-- Bruce
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr