From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7ABA0BCA9 for ; Fri, 6 May 2005 05:22:59 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j463MxD0025033 for ; Fri, 6 May 2005 05:22:59 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA16763 for ; Fri, 6 May 2005 05:22:58 +0200 (MET DST) Received: from web90105.mail.scd.yahoo.com (web90105.mail.scd.yahoo.com [66.218.94.76]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id j463Mv6L025027 for ; Fri, 6 May 2005 05:22:58 +0200 Received: (qmail 10950 invoked by uid 60001); 6 May 2005 03:22:56 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=wK97bKxjROhCvBRk1SdGvvNg1j2hoYe1G4J7eGBA9LEh4pSoPZilBS5Vn60js4n6IZHdWbb05WVWLd7pcvx/TL7EPRyp5aznQ3kAAy2VrlZy/LrXH0p+NJ/+biNvgwhF0WkVdx70eutMssb4+AklBMnwt73moXVmeaObwfJXCMY= ; Message-ID: <20050506032256.10948.qmail@web90105.mail.scd.yahoo.com> Received: from [69.110.44.39] by web90105.mail.scd.yahoo.com via HTTP; Thu, 05 May 2005 20:22:56 PDT Date: Thu, 5 May 2005 20:22:56 -0700 (PDT) From: Charles Martin Subject: unboxing options To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 427AE313.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 427AE311.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; unboxing:01 damien:01 damien:01 ocaml:01 foo:01 mutable:01 foo:01 mutable:01 option':01 unboxing:01 ...:98 ...:98 wrote:01 doligez:01 structures:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=2.2 required=5.0 tests=FORGED_YAHOO_RCVD autolearn=disabled version=3.0.2 X-Spam-Level: ** This is reviving a thread from last summer, but I recently became interested in the problem: Damien Doligez wrote in message news:... > 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