Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] assertions or exceptions?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Hughes <jfh@c...>
Subject: RE: [Caml-list] Unboxing options, was RE: assertions or exceptions?
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