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 RAA32602; Thu, 15 Jul 2004 17:31:11 +0200 (MET DST) 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 RAA00376 for ; Thu, 15 Jul 2004 17:31:10 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6FFV8SH010863 for ; Thu, 15 Jul 2004 17:31:08 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i6FFV3i13896 for ; Thu, 15 Jul 2004 10:31:05 -0500 (CDT) Date: Thu, 15 Jul 2004 10:38:14 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Ocaml Mailing List Subject: [Caml-list] Unboxing options, was RE: assertions or exceptions? In-Reply-To: <7f8e92aa04071501035091cbe9@mail.gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 40F6A33C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; unboxing:01 boxing:01 unboxing:01 unbox:01 null:01 assertions:01 preprocessor:02 pointer:03 pointer:03 variable:03 object:03 allocated:03 redirect:95 exceptions:04 exceptions:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk One of the problems with returning error conditions instead of throwing exceptions is the cost of boxing a 'a option. I'd like to advocate for the idea of unboxing 'a options. The idea works like this: None, rather than being represented internally as an integer value, would instead be an invalid pointer- either the NULL pointer or a pointer to a specially allocated object in a memory space that is never collected. But the key idea is that None is a value that can never be a valid variable value. Once that is the case, we don't need to box Some 'a, we can unbox it. I can see two disadvantages with this proposal. The first is that it breaks backwards compatibility. Code compiled to work the new way won't work with code compiled to work the old way. C code would have to be changed (although the difference would be pretty easy to manage with some preprocessor work). The second problem is that Some(None) isn't representable- that'd just be None. Thoughts? -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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