<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2005/05/84b98879bcb504fb728dfba2b6103b66"
  from="Charles Martin &lt;chaspost@y...&gt;"
  author="Charles Martin"
  date="2005-05-06T03:22:59"
  subject="unboxing options"
  prev="2005/05/bc5084b4ee4838f0829f9e1f0d319f39"
  next="2005/05/17df3a6105a273259ce6eefd7650869b"
  next-in-thread="2005/05/58267795e404d23e6686968eacd8d67e"
  prev-thread="2005/05/bc5084b4ee4838f0829f9e1f0d319f39"
  next-thread="2005/05/87479e8242941e44a1b561e930931482"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="unboxing options">
<msg 
  url="2005/05/84b98879bcb504fb728dfba2b6103b66"
  from="Charles Martin &lt;chaspost@y...&gt;"
  author="Charles Martin"
  date="2005-05-06T03:22:59"
  subject="unboxing options">
<msg 
  url="2005/05/58267795e404d23e6686968eacd8d67e"
  from="Christophe Raffalli &lt;christophe.raffalli@u...&gt;"
  author="Christophe Raffalli"
  date="2005-05-10T18:19:14"
  subject="Re: [Caml-list] unboxing options">
<msg 
  url="2005/05/044060475aa4fbf6c9f1d9f9e4e03e1a"
  from="Mike Hamburg &lt;hamburg@f...&gt;"
  author="Mike Hamburg"
  date="2005-05-11T17:19:41"
  subject="Re: [Caml-list] unboxing options">
<msg 
  url="2005/05/839576f084d909ebd28f2dd64dbf5018"
  from="Christophe Raffalli &lt;christophe.raffalli@u...&gt;"
  author="Christophe Raffalli"
  date="2005-05-11T18:50:24"
  subject="Re: [Caml-list] unboxing options">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
This is reviving a thread from last summer, but I
recently became interested in the problem:

Damien Doligez &lt;damien.doli...@inria.fr&gt; wrote in
message news:&lt;fa.eok2n4f.141k5pt@ifi.uio.no&gt;...
&gt; Finally, Jacques was not quite right in asserting
that most options
&gt; are short-lived.  This is only true if you don't use
"option" in your
&gt; main long-lived data structure.  Most seasoned OCaml
programmers know
&gt; it, and sometimes it leads to rather contorted data
structures.

How easy would it be to add an 'optional' keyword for
record types? For example:

    type 'a foo = { one : 'a option; mutable two : 'a
option }

would become:

    type 'a foo = { optional one : 'a; optional
mutable two : 'a }

Where the latter would unbox the options in the
representation. The
usage would be the same:

    let foo = { one = Some 0; two = None }
    match foo.one with None -&gt; ... | Some x -&gt; ...
    foo.two &lt;- None
    foo.two &lt;- Some x

This 'solves' the 'option option' problem by
supporting exactly one level of unboxing for records.
My guess is that this would take care of most of the
long-term data structure needs.

Charles



		
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

</contents>

</message>

