From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA02407 for caml-redistribution; Thu, 28 Jan 1999 21:01:08 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA17556 for ; Thu, 28 Jan 1999 20:57:12 +0100 (MET) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA18723 for ; Thu, 28 Jan 1999 20:57:10 +0100 (MET) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.2/8.9.2/best.sh) with ESMTP id LAA06856 for ; Thu, 28 Jan 1999 11:57:10 -0800 (PST) Date: Thu, 28 Jan 1999 11:57:09 -0800 (PST) From: Brian Rogoff To: caml-list@inria.fr Subject: Re: Array interface question In-Reply-To: <199901242136.WAA13264@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis On Sun, 24 Jan 1999, Pierre Weis wrote: > The Some (Some ...) problem could be solve if option where not only a > datatype but ... an option of record field names (or even constructor > names), analoguous to the mutable annotation for record fields. You > could write > > type person = { option name : string; option age : int};; > > This way the None values can be introduced by the compiler when > building a value of type person, for each optional field with no > associated value. The Some constructors would be ommitted from the > representation as desired. At pattern matching you may write None as a > valid pattern for an optional field, and write the normal expected > pattern otherwise (no need to write a Some constructor). In addition, > you could set once an optional field with some value, the compiler > checking that this field is indeed None before setting the new value. This is an interesting idea, but I fear that for my particular problem this is not helpful. For example, lets say I want to represent a Sequence abstraction as an array of arrays, where the top level array grows by doubling when an addition forces a resizing, and the data blocks are of fixed size. Currently, I represent the indirection array as a "'a array option Dynarray.t", and all of my access functions contain a pattern match to extract the data array. Its this needless wrapping and unwrapping (forced since I don't want to have "fill" elements in the interface) of the array elements that I don't like, though I don't know of any better option. -- Brian (yes, the pun is intentional)