Date: Fri, 22 Jan 1999 12:05:41 -0800 (PST)
From: Brian Rogoff <bpr@best.com>
To: caml-list@inria.fr
Subject: Re: Array interface question
In-Reply-To: <199901221921.UAA10085@pauillac.inria.fr>
On Fri, 22 Jan 1999, Pierre Weis wrote:
> > Why is there no creation function which does not take a default
> > value for filling the array?
> [...]
> >
> > -- Brian
>
> This is due to the coexistance in Caml of polymorphism and mutable
> values. The system would be unsafe if we were able to allocate
> polymorphic mutable values (those mutable values could be filled
> afterwards with values of unrelated types, and hence would break the
> homogeneous sequence nature of arrays, and then may be read back with
> types unrelated to their proper types).
Thanks, I should have known that was it.
Given this, I'd like to request a Sequence abstraction like the one in
SRC Modula-3, which permits addition and removal at either end, and random
access, in expected constant time, for inclusion in the stdlib. I have
several times had need of such an ADT (usually I only need to add at one
end and have random access), most recently in a BDD library I'm writing.
Any suggestions on how to write Sequence elegantly (and safely of course ;-)
in OCaml as it stands?
Probably having a default value for dynamic arrays is not so bad...
-- Brian
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET