<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/aea555497a0e491121edbc92b458eed8"
  from="Pierre Weis &lt;pierre.weis@i...&gt;"
  author="Pierre Weis"
  date="2002-07-12T12:41:19"
  subject="Re: [Caml-list] printf hook"
  prev="2002/07/b802813d2c7d950957fa291bf3aaf35f"
  next="2002/07/fa31c3e21f30d1d49387b8135813c2c3"
  prev-in-thread="2002/07/041a364c6a3fa76a72e798b3892d9d10"
  next-in-thread="2002/06/d864d943af4f4f5c220f77dfe19bafb9"
  prev-thread="2002/06/122e975cdaf9b905dc477cf8f71192df"
  next-thread="2002/06/d01dc030604f55b666c1a41008a9543a"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] printf hook">
<msg 
  url="2002/06/01e60aa240c57c708eb1750ec9ecb3d8"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2002-06-26T15:02:44"
  subject="[Caml-list] printf hook">
<msg 
  url="2002/06/df38772e97cd0ebb80a01cbe348663e3"
  from="Jean-Christophe Filliatre &lt;filliatr@l...&gt;"
  author="Jean-Christophe Filliatre"
  date="2002-06-26T15:31:12"
  subject="Re: [Caml-list] printf hook">
<msg 
  url="2002/07/041a364c6a3fa76a72e798b3892d9d10"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2002-07-12T10:22:14"
  subject="Re: [Caml-list] printf hook">
<msg 
  url="2002/07/aea555497a0e491121edbc92b458eed8"
  from="Pierre Weis &lt;pierre.weis@i...&gt;"
  author="Pierre Weis"
  date="2002-07-12T12:41:19"
  subject="Re: [Caml-list] printf hook">
</msg>
</msg>
</msg>
<msg 
  url="2002/06/d864d943af4f4f5c220f77dfe19bafb9"
  from="Remi VANICAT &lt;vanicat@l...&gt;"
  author="Remi VANICAT"
  date="2002-06-26T15:48:21"
  subject="Re: [Caml-list] printf hook">
</msg>
</msg>
</thread>

<contents>
&gt; I just found something quite funny :
&gt; 
&gt; let print x =
&gt;     printf "BEGIN";
&gt;     printf x;
&gt;     flush stdout
&gt; 
&gt; print "test";;
&gt; print "%d" 10; (** TOO MUCH ARGS **)

This is normal, isn't it ?

&gt; ============
&gt; 
&gt; let print x =
&gt;     printf "BEGIN";
&gt;     let r = printf x in
&gt;     flush stdout;
&gt;     r
&gt; 
&gt; print "test";
&gt; print "%d" 10; (** WORKING **)

This is also perfectly regular: your code

let print x =
  printf "BEGIN";
  let r = printf x in
  flush stdout;
  r

is functionally equivalent to

let print x =
  let r = printf x in
  r

which is again functionally equivalent to

let print x = printf x

which is again equivalent to

let print = printf

The type checker gives an hint on that fact, since print is reported
having the same type as printf:

        Objective Caml version 3.04+15 (2002-06-18)

#open Printf;;
# let print x =
  printf "BEGIN";
  let r = printf x in
  flush stdout;
  r;;
val print : ('a, out_channel, unit) format -&gt; 'a = &lt;fun&gt;
# printf;;
- : ('a, out_channel, unit) format -&gt; 'a = &lt;fun&gt;

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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

</contents>

</message>

