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 SAA02294; Thu, 15 Jul 2004 18:25:06 +0200 (MET DST) 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 SAA02882 for ; Thu, 15 Jul 2004 18:25:05 +0200 (MET DST) Received: from salt.cs.brown.edu (salt.cs.brown.edu [128.148.32.122]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6FGP3EV019989 for ; Thu, 15 Jul 2004 18:25:04 +0200 Received: from localhost (localhost [127.0.0.1]) by salt.cs.brown.edu (Postfix) with ESMTP id 216CAD86CC for ; Thu, 15 Jul 2004 12:25:03 -0400 (EDT) Received: from salt.cs.brown.edu ([127.0.0.1]) by localhost (salt [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07467-10 for ; Thu, 15 Jul 2004 12:25:02 -0400 (EDT) Received: from null.cs.brown.edu (null.cs.brown.edu [128.148.38.190]) by salt.cs.brown.edu (Postfix) with ESMTP id C55B8D8705 for ; Thu, 15 Jul 2004 12:25:00 -0400 (EDT) Received: from clark.cs.brown.edu (clark [128.148.31.45]) by null.cs.brown.edu (Postfix) with ESMTP id 6F7A23D31 for ; Thu, 15 Jul 2004 12:25:00 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by clark.cs.brown.edu (Postfix) with ESMTP id 3323010EF0D for ; Thu, 15 Jul 2004 12:25:00 -0400 (EDT) Received: from clark.cs.brown.edu ([127.0.0.1]) by localhost (clark [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23603-04 for ; Thu, 15 Jul 2004 12:25:00 -0400 (EDT) Received: from spikeshomepc (meylan-1-82-225-49-106.fbx.proxad.net [82.225.49.106]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by clark.cs.brown.edu (Postfix) with ESMTP id 54A1310EF06 for ; Thu, 15 Jul 2004 12:24:59 -0400 (EDT) Reply-To: From: "John Hughes" To: "'Ocaml Mailing List'" Subject: RE: [Caml-list] Unboxing options, was RE: assertions or exceptions? Date: Thu, 15 Jul 2004 18:25:00 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcRqgZ4o3nrQcHKfSkq2oybFb7KT2gABmcJw Message-Id: <20040715162459.54A1310EF06@clark.cs.brown.edu> X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at cs.brown.edu X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at cs.brown.edu X-Miltered: at nez-perce with ID 40F6AFDF.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 unboxing:01 --john:01 2004:99 caml-list:01 unboxing:01 boxing:01 unbox:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 caml-bugs:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'd like to suggest that this isn't really a problem. The key is the idea of "exception", which is that it's an *exception* to what ordinarily happens. The same goes for errors -- they should be exceptional. As such, making the code associated with these things more efficient (as opposed to more readable, maintainable, whatever else) should be WAAAY down on your priority list. --John Hughes > -----Original Message----- > From: owner-caml-list@pauillac.inria.fr > [mailto:owner-caml-list@pauillac.inria.fr] On Behalf Of Brian Hurt > Sent: Thursday, July 15, 2004 5:38 PM > To: Ocaml Mailing List > Subject: [Caml-list] Unboxing options, was RE: assertions or > exceptions? > > > 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 > ------------------- 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