caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* unboxing options
@ 2005-05-06  3:22 Charles Martin
  2005-05-10 18:19 ` [Caml-list] " Christophe Raffalli
  0 siblings, 1 reply; 4+ messages in thread
From: Charles Martin @ 2005-05-06  3:22 UTC (permalink / raw)
  To: caml-list

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

Damien Doligez <damien.doli...@inria.fr> wrote in
message news:<fa.eok2n4f.141k5pt@ifi.uio.no>...
> Finally, Jacques was not quite right in asserting
that most options
> are short-lived.  This is only true if you don't use
"option" in your
> main long-lived data structure.  Most seasoned OCaml
programmers know
> 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 -> ... | Some x -> ...
    foo.two <- None
    foo.two <- 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-05-11 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-06  3:22 unboxing options Charles Martin
2005-05-10 18:19 ` [Caml-list] " Christophe Raffalli
2005-05-11 17:18   ` Mike Hamburg
2005-05-11 18:50     ` Christophe Raffalli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).