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 TAA00055; Tue, 14 Jan 2003 19:38:09 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA00775 for caml-list@pauillac.inria.fr; Tue, 14 Jan 2003 19:38:09 +0100 (MET) 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 MAA19862 for ; Tue, 14 Jan 2003 12:18:52 +0100 (MET) Received: from julie.univ-savoie.fr (univax.univ-savoie.fr [193.48.120.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0EBIpr23645 for ; Tue, 14 Jan 2003 12:18:52 +0100 (MET) Received: from post.bourget.univ-savoie.fr (post.bourget.univ-savoie.fr [193.48.120.73]) by julie.univ-savoie.fr (8.9.3/jtpda-5.3.3) with ESMTP id MAA77302 ; Tue, 14 Jan 2003 12:18:50 +0100 (CET) Received: from univ-savoie.fr (d85.lama.univ-savoie.fr [193.48.123.85]) by post.bourget.univ-savoie.fr (8.12.3/jtpda-5.4) with ESMTP id h0EBIkPt003794 ; Tue, 14 Jan 2003 12:18:46 +0100 Message-ID: <3E23F225.3060302@univ-savoie.fr> Date: Tue, 14 Jan 2003 12:19:01 +0100 From: Christophe Raffalli User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: fabrice@lefessant.net CC: Hal Daume III , Caml Mailing List Subject: Re: [Caml-list] unboxing of unary datatypes References: <15907.57089.759815.660410@lachesis.inria.fr> X-Enigmail-Version: 0.65.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigF5FA62C6DDA0AF5EB305A9FD" Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigF5FA62C6DDA0AF5EB305A9FD Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Fabrice Le Fessant wrote: >> I originally had a very calculation intensive program which used a data >> type which looked like: >> >> > type foo = Foo of float >> >> I could just have easily used floats, but I wanted to ensure that I didn't >> do anything stupid (like try to multiply a foo by a float), so I did this >> boxing so the type-checker would help me out. > > > In ocaml, there are no overloaded operations, not automatic > conversions to integers, so that if you don't need to do that at > all. The type system will always force you to use the operations on > floats, or to convert them to foo before multiplying them by foo. > > >> But based on some non-scientific tests, it seems that this isn't the case, >> and that the original foo type is actually represented using a >> pointer-to-float. >> >> I cannot imagine why this is the case (coming from a Haskell world, there >> is a difference there between these two types due to laziness, but since >> ocaml is strict, I figured this wouldn't be the case). > > > If you want to keep the interface with C simple, you need an > easy/efficient way to move ocaml values between caml functions and C > functions. This is done by specifying the internal representation of > ocaml values so that C functions know how to manipulate them. If you > let the compiler optimize the representation of values, C functions > won't be able to access ocaml values anymore (well, it will be more > complicated, since you need to attach by some way a description of the > representation of each value passed to a C function...). > > Of course, it could be done by some annotation, telling the compiler > that the value will never be passed to a C function. But this would > introduce useless complexity into the language. Or let the compiler produce a C header describing the representation of the data type, when it is optimized ! It would be nice if Data type with one unary constructor and many constant constructors could be optimized by using the fact that pointer are always even (and non zero), so we can use the zero and/or the odd numbers to represent the constant constructor. This would optimize a lot the 'a option type. > - Fabrice > ------------------- > 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 -- Christophe Raffalli Université de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI --------------------------------------------- IMPORTANT: this mail is signed using PGP/MIME At least Enigmail/Mozilla, mutt or evolution can check this signature --------------------------------------------- --------------enigF5FA62C6DDA0AF5EB305A9FD Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE+I/IlSQDyWB/+xBwRAkOHAKDD9qpybxWgQ6tbjGAtlEYpJXGHGQCgmJhV ftY+XKMt9LS7M/XGCTs5Yxw= =z2Ho -----END PGP SIGNATURE----- --------------enigF5FA62C6DDA0AF5EB305A9FD-- ------------------- 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