Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Array interface question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Rogoff <bpr@b...>
Subject: Re: Array interface question
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)