caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] eval order and 'and'
@ 2002-09-11  1:21 Chris Hecker
  2002-09-11  7:30 ` malc
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Hecker @ 2002-09-11  1:21 UTC (permalink / raw)
  To: caml-list


Does "let a and b in" guarantee a is evaluated before b, like "let a in let 
b in" does?

Chris

PS.  I don't think this is a FAQ, but it's basically impossible to 
construct a search that finds this specific question, so who knows!  ;)

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] eval order and 'and'
  2002-09-11  1:21 [Caml-list] eval order and 'and' Chris Hecker
@ 2002-09-11  7:30 ` malc
  0 siblings, 0 replies; 6+ messages in thread
From: malc @ 2002-09-11  7:30 UTC (permalink / raw)
  To: Chris Hecker; +Cc: caml-list

On Tue, 10 Sep 2002, Chris Hecker wrote:

> Does "let a and b in" guarantee a is evaluated before b, like "let a in let 
> b in" does?
> 
> Chris
> 
> PS.  I don't think this is a FAQ, but it's basically impossible to 
> construct a search that finds this specific question, so who knows!  ;)

<quote>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] eval order and 'and'
  2002-09-11  7:47 ` Sven LUTHER
@ 2002-09-11  8:32   ` Hendrik Tews
  0 siblings, 0 replies; 6+ messages in thread
From: Hendrik Tews @ 2002-09-11  8:32 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] eval order and 'and'
  2002-09-11  5:05 Arturo Borquez
  2002-09-11  7:19 ` Chris Hecker
@ 2002-09-11  7:47 ` Sven LUTHER
  2002-09-11  8:32   ` Hendrik Tews
  1 sibling, 1 reply; 6+ messages in thread
From: Sven LUTHER @ 2002-09-11  7:47 UTC (permalink / raw)
  To: Arturo Borquez; +Cc: Chris Hecker, caml-list

On Wed, Sep 11, 2002 at 01:05:46AM -0400, Arturo Borquez wrote:
> Chris Hecker <checker@d6.com> wrote:
> 
> >
> >Does "let a and b in" guarantee a is evaluated before b, like "let a in let 
> >b in" does?
> >
> Sorry but I don't understand the purpose of your question.
> If a and b are functions with 'related side effects' the secure
> way should be the later ('let a in let b ..'), otherwise
> the order of evaluation in the first case is irrelevant
> as a and b are two unrelated functions (with no side effects),
> or 'let a and b in ..' is the same as 'let b and a in ..' 

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).

But then again, it could be different in bytecode and in native code.

Friendly,

Sven Luther
-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Caml-list] eval order and 'and'
  2002-09-11  5:05 Arturo Borquez
@ 2002-09-11  7:19 ` Chris Hecker
  2002-09-11  7:47 ` Sven LUTHER
  1 sibling, 0 replies; 6+ messages in thread
From: Chris Hecker @ 2002-09-11  7:19 UTC (permalink / raw)
  To: Arturo Borquez; +Cc: caml-list


> >Does "let a and b in" guarantee a is evaluated before b, like "let a in let
> >b in" does?
>Sorry but I don't understand the purpose of your question.

I was simply asking if the 'and' construct guarantees order or not (is a 
"sequence point" in C terminology), that's all.

Chris

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Caml-list] eval order and 'and'
@ 2002-09-11  5:05 Arturo Borquez
  2002-09-11  7:19 ` Chris Hecker
  2002-09-11  7:47 ` Sven LUTHER
  0 siblings, 2 replies; 6+ messages in thread
From: Arturo Borquez @ 2002-09-11  5:05 UTC (permalink / raw)
  To: Chris Hecker; +Cc: caml-list

Chris Hecker <checker@d6.com> wrote:

>
>Does "let a and b in" guarantee a is evaluated before b, like "let a in let 
>b in" does?
>
Sorry but I don't understand the purpose of your question.
If a and b are functions with 'related side effects' the secure
way should be the later ('let a in let b ..'), otherwise
the order of evaluation in the first case is irrelevant
as a and b are two unrelated functions (with no side effects),
or 'let a and b in ..' is the same as 'let b and a in ..' 

Regards.
-- 
Arturo Borquez


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-09-11  8:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-11  1:21 [Caml-list] eval order and 'and' Chris Hecker
2002-09-11  7:30 ` malc
2002-09-11  5:05 Arturo Borquez
2002-09-11  7:19 ` Chris Hecker
2002-09-11  7:47 ` Sven LUTHER
2002-09-11  8:32   ` Hendrik Tews

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).