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 BAA06145; Tue, 14 Jan 2003 01:08:37 +0100 (MET) 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 BAA06316 for ; Tue, 14 Jan 2003 01:08:36 +0100 (MET) Received: from nitro.isi.edu (nitro.isi.edu [128.9.208.207]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h0E08Z521555 for ; Tue, 14 Jan 2003 01:08:35 +0100 (MET) Received: from moussor.isi.edu (moussor.isi.edu [128.9.208.41]) by nitro.isi.edu (8.11.6/8.11.2) with ESMTP id h0E08XG20470 for ; Mon, 13 Jan 2003 16:08:33 -0800 (PST) Received: from localhost (hdaume@localhost) by moussor.isi.edu (8.8.7/8.8.6) with ESMTP id AAA29944 for ; Tue, 14 Jan 2003 00:08:32 GMT X-Authentication-Warning: moussor.isi.edu: hdaume owned process doing -bs Date: Mon, 13 Jan 2003 16:08:32 -0800 (PST) From: Hal Daume III To: Caml Mailing List Subject: [Caml-list] unboxing of unary datatypes Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi all, 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. I had always assumed that once the code got past the typechecker, the ocaml compiler would optimize away the constructor, so that the resulting code would be as efficient as if I had just done > type foo = float 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). Can someone explain this to me? Why doesn't the compiler optimize out the constructor? - Hal -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume ------------------- 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