Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] eval order and 'and'
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@t...>
Subject: Re: [Caml-list] eval order and 'and'
Sven LUTHER writes:
   Date: Wed, 11 Sep 2002 09:47:53 +0200
   Subject: Re: [Caml-list] eval order and 'and'
   
   So he can do things like :
   
   if x <> 0 and 1 / x ... 
   
   like it is possible to do in C, instead of doing :
   
   if x <> 0 then if 1 / x ...
   
   which gives more lines of code, and needs to redefine two time the else
   condition.
   
   Anyway, i don't think the order is defined, but in any case, i guess
   it would be revere sequential if anything (execution starts from the
   right).
   
IMO you are mixing things up, "and" is not an operator and 

   if x <> 0 and 1 / x ... 

is not legal ocaml. 

For let a = ex1 and b = ex2 ... the manual says that the
evaluation is unspecified (6.7.1. local definitions).

For the logical operators (&&, &, ||, or) the manual specifies left
to right (non-strict) evaluation (Module Pervasives).

Bye,

Hendrik
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners