<?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="2003/11/92dbb3eff27c1305dfb13cc95807a0c3"
  from="Kim Nguyen &lt;nguyen@b...&gt;"
  author="Kim Nguyen"
  date="2003-11-22T14:25:55"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()"
  prev="2003/11/47c7a7b20eb96e9e1835662fe1651255"
  next="2003/11/26ef24002e41d7ebabfb7229a3904059"
  prev-in-thread="2003/11/26ef24002e41d7ebabfb7229a3904059"
  next-in-thread="2003/11/6ee5dd7ed01812dc5e6b44c4bdc4eaff"
  prev-thread="2003/11/b9a42a206431fb25d03c3e4bf43cc125"
  next-thread="2003/11/58c657c03c7683b0214401b6eee2a21f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Accuracy of Gc.stat ()">
<msg 
  url="2003/11/f5ceb88194f4324b692f89b6f3398ff2"
  from="Daniel_Bünzli &lt;daniel.buenzli@e...&gt;"
  author="Daniel_Bünzli"
  date="2003-11-19T17:52:08"
  subject="[Caml-list] Accuracy of Gc.stat ()">
<msg 
  url="2003/11/974acf8ee1bf674c02076f709368a862"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-11-21T16:45:52"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()">
</msg>
<msg 
  url="2003/11/002147abdef4f6fe5248093cd8c75a75"
  from="Kim Nguyen &lt;nguyen@b...&gt;"
  author="Kim Nguyen"
  date="2003-11-22T00:18:27"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()">
<msg 
  url="2003/11/b0824ff17e581379b1c4a9a60ef71fb5"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-11-22T11:44:11"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()">
<msg 
  url="2003/11/8f2405258c33a120ad0ca9f46f985eb6"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-11-22T11:49:12"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()">
<msg 
  url="2003/11/47c7a7b20eb96e9e1835662fe1651255"
  from="Daniel_Bünzli &lt;daniel.buenzli@e...&gt;"
  author="Daniel_Bünzli"
  date="2003-11-22T14:20:36"
  subject="Self-detection of native code execution (Was Re: [Caml-list] Accuracy of Gc.stat ())">
<msg 
  url="2003/11/26ef24002e41d7ebabfb7229a3904059"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-11-22T14:28:54"
  subject="Re: Self-detection of native code execution (Was Re: [Caml-list] Accuracy of Gc.stat ())">
</msg>
</msg>
<msg 
  url="2003/11/92dbb3eff27c1305dfb13cc95807a0c3"
  from="Kim Nguyen &lt;nguyen@b...&gt;"
  author="Kim Nguyen"
  date="2003-11-22T14:25:55"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()">
<msg 
  url="2003/11/6ee5dd7ed01812dc5e6b44c4bdc4eaff"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-11-22T14:31:14"
  subject="Re: [Caml-list] Accuracy of Gc.stat ()">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hello,

On Sat, 22 Nov 2003 11:49:08 +0000
Richard Jones &lt;rich@annexia.org&gt; wrote:


&gt; &gt; Neat trick. This _ought_ to work, but it doesn't for some reason:
&gt; &gt; 
&gt; &gt; 	let arg = (true, false) 
&gt; &gt; 	external is_bytecode : bool * bool -&gt; bool = "%field0" "%field1" 
&gt; &gt;  
&gt; &gt; 	let () = 
&gt; &gt; 	  if is_bytecode arg then 
&gt; &gt; 	    print_endline "Bytecode!" 
&gt; &gt; 	  else 
&gt; &gt; 	    print_endline "Native!" 
&gt; &gt; 
&gt; &gt; Perhaps someone can explain why ...
&gt; 
&gt; OK, closer inspection of the manual[*] reveals why this doesn't work.
&gt; Surely OCaml should flag the above code as a bug, because there are
&gt; fewer than the magical 6 arguments?
&gt; 
&gt; Rich.

Well, my guess is that '%' primitives pre-defined in Ocaml are not compiled as
function. Some are just a way to bypass the typechecker (like %identity) and others
are directly translated to a sequence of bytecode/native instructions and inlined 
in the code. Thus when you use a "%primitive" in an external only the first declaration
 would by used, and so, the %field1 above would get ignored by the compiler. 
You can see it if you try to mix both kinds of primitive :

external is_bytecode : bool * bool -&gt; bool = "field0_bytecode" "%field1" 

the compilation process fine but at link time, the linker complain about an undefiened
 symbol '$25field1'.
if you use :
external is_bytecode : bool * bool -&gt; bool = "%field0" "field1_native"
then the "field1_native" is ignored %field0 is used in both cases.

Anyhow, I just meant to toy with the compiler and don't think using this 'feature' of
the compiler should be considered safe, as it is not specified in the documentation
(unless we have clearer explanation by an Ocaml guru :-). It could be a nice feature
though.

Regards,

Kim.

</contents>

</message>

