From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA12770; Sat, 22 Nov 2003 15:28:54 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA12865 for ; Sat, 22 Nov 2003 15:28:53 +0100 (MET) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAMESq118186 for ; Sat, 22 Nov 2003 15:28:52 +0100 (MET) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1ANYkm-0003Ec-00 for ; Sat, 22 Nov 2003 14:28:52 +0000 Date: Sat, 22 Nov 2003 14:28:52 +0000 Cc: caml-list@inria.fr Subject: Re: Self-detection of native code execution (Was Re: [Caml-list] Accuracy of Gc.stat ()) Message-ID: <20031122142852.GA12413@redhat.com> References: <1970C334-1AB9-11D8-ADB3-000393DBC266@epfl.ch> <20031122012054.0dbd44e2.nguyen@bk.ru> <20031122114350.GA11531@redhat.com> <20031122114908.GA11593@redhat.com> <0C871798-1CF7-11D8-8FEF-000393DBC266@epfl.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0C871798-1CF7-11D8-8FEF-000393DBC266@epfl.ch> User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 endline:01 endline:01 bug:01 kim:99 ignores:01 bytecomp:01 translcore:01 freshmeat:01 obstacle:01 vanier:01 ltd:98 compiler:01 bool:01 bool:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, Nov 22, 2003 at 03:20:40PM +0100, Daniel B?nzli wrote: > > Le 22 nov. 03, ? 12:49, Richard Jones a ?crit : > > >>Neat trick. This _ought_ to work, but it doesn't for some reason: > >> > >> let arg = (true, false) > >> external is_bytecode : bool * bool -> bool = "%field0" "%field1" > >> > >> let () = > >> if is_bytecode arg then > >> print_endline "Bytecode!" > >> else > >> print_endline "Native!" > >> > >>Perhaps someone can explain why ... > > Nice try, too bad it doesn't work. I would even prefer that one : > > let arg = true > external is_bytecode : bool -> bool = "%identity" "%boolnot" > > let () = > if is_bytecode arg then > print_endline "Bytecode!" > else > print_endline "Native!" > > > >OK, closer inspection of the manual[*] reveals why this doesn't work. > >Surely OCaml should flag the above code as a bug, because there are > >fewer than the magical 6 arguments? > > The strange thing is that the function given by Kim also have fewer > than 6 arguments. True, but his code doesn't actually use the values of the arguments passed to the C functions. What is needed is a primitive function which ignores its arguments and returns a known value. But I don't think there is such a primitive in the current compiler. (Not as far as I can see by looking at bytecomp/translcore.ml anyway). Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - improving website return on investment "One serious obstacle to the adoption of good programming languages is the notion that everything has to be sacrificed for speed. In computer languages as in life, speed kills." -- Mike Vanier ------------------- 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