Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: John Carr <jfc@mit.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Unboxing options, was RE: assertions or exceptions?
Date: Thu, 15 Jul 2004 15:48:30 -0500 (CDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0407151524450.4202-100000@localhost.localdomain> (raw)
In-Reply-To: <200407151956.i6FJuJJJ004332@psi-phi.mit.edu>

On Thu, 15 Jul 2004, John Carr wrote:

> > type 'a option is the same as type 'a option option
> > Some Some 1 is identical to Some 1
> > Some None is identical to None
> 
> So use true 0 as opposed to the integer 0 internally represented as 1
> to mean "None".  This adds some complexity but may be worth the effort
> as options are common.

What's the representation of Some(None) then?  The Some() goes away, and 
the containing value is unboxed- it turns out to be the same as just None.  
There is no way to differentiate Some(Some(Some(Some(None)))) from None.

Which I mentioned in my original post.

I can see three ways around this.  First, just change the behavior, 
probably adding a switch into the compiler to issue a warning whenever it 
sees a type of the form 'a option option.  This would be under the 
assumption that very little code actually does options of options (I don't 
think I've seen any- not to say it doesn't exist, just to say it's not 
common).  Second possibility, have the compiler detect when it's doing an 
option of an option, and forcibly insert boxing at that point.  Third 
possibility: create a new type, 'a nullable, that has this as the defined 
behavior.

I've seen designs contort themselves in an attempt to avoid the overhead 
of boxing options- starting with enums in ExtLib.  This is an overhead 
which doesn't have to exist, and we should at least consider eliminating 
it.

-- 
"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


  reply	other threads:[~2004-07-15 20:41 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-15  8:03 [Caml-list] " Radu Grigore
2004-07-15 10:18 ` Richard Jones
2004-07-15 10:28   ` Daniel Andor
2004-07-15 12:49   ` Radu Grigore
2004-07-15 13:33     ` Richard Jones
2004-07-15 13:58       ` Radu Grigore
2004-07-16 18:53         ` Aleksey Nogin
2004-07-17  2:55           ` John Prevost
2004-07-17 14:24             ` David MENTRE
2004-07-15 12:35 ` Jon Harrop
2004-07-15 13:45   ` Radu Grigore
2004-07-15 14:33     ` Jon Harrop
2004-07-15 15:05       ` Radu Grigore
2004-07-15 16:24     ` skaller
2004-07-15 15:38 ` [Caml-list] Unboxing options, was " Brian Hurt
2004-07-15 16:25   ` John Hughes
2004-07-15 17:00     ` Brian Hurt
2004-07-15 17:20   ` John Prevost
2004-07-15 19:14     ` Radu Grigore
2004-07-15 19:56     ` John Carr
2004-07-15 20:48       ` Brian Hurt [this message]
2004-07-15 20:49         ` John Carr
2004-07-15 21:15           ` John Prevost
2004-07-15 21:15           ` Karl Zilles
2004-07-15 21:26           ` Brian Hurt
2004-07-15 21:04       ` John Prevost
2004-07-15 21:17     ` skaller
2004-07-15 21:35       ` Brian Hurt
2004-07-15 21:51         ` skaller
2004-07-15 21:42       ` skaller
2004-07-16  0:35     ` Jacques GARRIGUE
2004-07-16  1:03       ` John Prevost
2004-07-16  2:00         ` Jacques GARRIGUE
2004-07-16 16:40         ` Xavier Leroy
2004-07-19  8:58           ` Damien Doligez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0407151524450.4202-100000@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=jfc@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox