From: Charles Martin <chaspost@yahoo.com>
To: caml-list@inria.fr
Subject: unboxing options
Date: Thu, 5 May 2005 20:22:56 -0700 (PDT) [thread overview]
Message-ID: <20050506032256.10948.qmail@web90105.mail.scd.yahoo.com> (raw)
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
next reply other threads:[~2005-05-06 3:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-06 3:22 Charles Martin [this message]
2005-05-10 18:19 ` [Caml-list] " Christophe Raffalli
2005-05-11 17:18 ` Mike Hamburg
2005-05-11 18:50 ` Christophe Raffalli
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=20050506032256.10948.qmail@web90105.mail.scd.yahoo.com \
--to=chaspost@yahoo.com \
--cc=caml-list@inria.fr \
/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