Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Evaluation Order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Tore Lund <tl001@o...>
Subject: Re: [Caml-list] Evaluation Order
Tore Lund wrote:
> 
>   # let _ =
>       print_string "before";
>       print_string "MIDDLE";
>       print_string "after";;
>   beforeMIDDLEafter- : unit = ()
> 
>   # let _ =
>       print_string "before";
>       Format.print_string "MIDDLE";
>       print_string "after";;
>   beforeafterMIDDLE- : unit = ()
> 
> What's going on here?  All I did was to add "Format".  Is not printing
> an "effet du bord"?

For that matter:

  # let a =  print_string "before" in
    let b =  print_string "MIDDLE" in
    let c =  print_string "after" in
    a; b; c;;
  beforeMIDDLEafter- : unit = ()

versus:

  # let a = print_string "before" in
    let b = Format.print_string "MIDDLE" in
    let c = print_string "after" in
    a; b; c;;
  beforeafterMIDDLE- : unit = ()

Okay.  So there is buffering at work that has little to do with OCaml. 
Which probably means that the only side-effects guaranteed to happen in
a certain order are those carried out by the runtime system itself. 
Hmmm, at the very least this makes it necessary to distinguish between
two species of side-effect.
-- 
    Tore

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