Re: Array interface question

From: Brian Rogoff (
Date: Thu Jan 28 1999 - 20:57:09 MET

Date: Thu, 28 Jan 1999 11:57:09 -0800 (PST)
From: Brian Rogoff <>
Subject: Re: Array interface question
In-Reply-To: <>

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)

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:19 MET