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 PAA11978; Sat, 22 Nov 2003 15:25:55 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA12371 for ; Sat, 22 Nov 2003 15:25:54 +0100 (MET) Received: from mx2.mail.ru (mx2.mail.ru [194.67.23.22]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAMEPr115272 for ; Sat, 22 Nov 2003 15:25:53 +0100 (MET) Received: from [81.56.190.171] (port=38784 helo=localhost) by mx2.mail.ru with smtp id 1ANYhs-000GFf-00; Sat, 22 Nov 2003 17:25:52 +0300 Date: Sat, 22 Nov 2003 15:28:16 +0100 From: Kim Nguyen To: Richard Jones Cc: caml-list@inria.fr Subject: Re: [Caml-list] Accuracy of Gc.stat () Message-Id: <20031122152816.20e089ba.nguyen@bk.ru> In-Reply-To: <20031122114908.GA11593@redhat.com> References: <1970C334-1AB9-11D8-ADB3-000393DBC266@epfl.ch> <20031122012054.0dbd44e2.nguyen@bk.ru> <20031122114350.GA11531@redhat.com> <20031122114908.GA11593@redhat.com> X-Mailer: Sylpheed version 0.9.6claws (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Sat__22_Nov_2003_15_28_16_+0100_UVxycZnYF.zio0iV" X-Loop: caml-list@inria.fr X-Spam: no; 0.00; kim:99 caml-list:01 endline:01 endline:01 bug:01 inlined:01 $25:99 kim:99 compiler:01 compiler:01 anyhow:01 bool:01 bool:01 ocaml:01 ocaml:01 X-Attachments: type="application/pgp-signature" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --Signature=_Sat__22_Nov_2003_15_28_16_+0100_UVxycZnYF.zio0iV Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Hello, On Sat, 22 Nov 2003 11:49:08 +0000 Richard Jones wrote: > > 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 ... > > 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? > > 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 -> 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 -> 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. --Signature=_Sat__22_Nov_2003_15_28_16_+0100_UVxycZnYF.zio0iV Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/v3KGGqhFkfuNlVkRApMQAKCFwV1KGAV6NTh6TN/UtMrn84k2ZgCfavZd iamAc21FtqtlTQH6kWM/Irs= =aHCI -----END PGP SIGNATURE----- --Signature=_Sat__22_Nov_2003_15_28_16_+0100_UVxycZnYF.zio0iV-- ------------------- 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