caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* boolean operators
@ 1995-06-08 13:17 CALLADINE Pierre
  1995-06-08 16:34 ` Pierre Weis
  0 siblings, 1 reply; 2+ messages in thread
From: CALLADINE Pierre @ 1995-06-08 13:17 UTC (permalink / raw)
  To: "liste de correspondants caml "


      Is there a deep (or theoretical) reason for the particular status of boolean 
  operators as "&" and "or"  ( "prefix &" is not valid, for instance ?)

-- 
Pierre Calladine
Universite de Poitiers -        e-mail : calla@matpts.univ-poitiers.fr
Dept. Informatique		Tel: 49 45 37 01
40 Avenue du Recteur Pineau     Fax  49 45 40 10
86022 Poitiers Cedex     




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

* Re: boolean operators
  1995-06-08 13:17 boolean operators CALLADINE Pierre
@ 1995-06-08 16:34 ` Pierre Weis
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre Weis @ 1995-06-08 16:34 UTC (permalink / raw)
  To: CALLADINE Pierre; +Cc: caml-list

> Is there a deep (or theoretical) reason for the particular status
> of boolean operators as "&" and "or"
> ( "prefix &" is not valid, for instance ?)

The problem is that there are no corresponding functions in Caml:
these syntactic constructs are equivalent to an if then else
expression, not to a function call to some primitive operation (as for
+ for example).

On the other hand, since Caml evaluation obeys call by value, there is
no means to define a function that does not evalute its
arguments. Hence you cannot define a function f such that
e1 & e2 could be equivalent to f e1 e2.

In effect, when e1 evaluates to false, the construct e1 & e2 returns
false and e2 is not evaluated. By contrast, the call f e1 e2 may
return some value but e2 will be evaluated before entering the body of
f.

Put it another way, & is a lazy construct: if e2 fails or does not
terminate then false & e2 evaluates to false, while any function call
with e2 as argument will fail or loop.

Pierre Weis
----------------------------------------------------------------------------
WWW Home Page: http://pauillac.inria.fr/~weis
Projet Cristal
INRIA, BP 105, F-78153 Le Chesnay Cedex (France)
E-mail: Pierre.Weis@inria.fr
Telephone: +33 1 39 63 55 98
Fax: +33 1 39 63 53 30
----------------------------------------------------------------------------




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

end of thread, other threads:[~1995-06-08 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-08 13:17 boolean operators CALLADINE Pierre
1995-06-08 16:34 ` Pierre Weis

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