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 PAA25080 for caml-redistribution; Sun, 24 Jan 1999 15:38:42 +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 VAA11173 for ; Fri, 22 Jan 1999 21:05:43 +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 VAA03620 for ; Fri, 22 Jan 1999 21:05:41 +0100 (MET) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.2/8.9.2/best.sh) with ESMTP id MAA18125 for ; Fri, 22 Jan 1999 12:05:41 -0800 (PST) Date: Fri, 22 Jan 1999 12:05:41 -0800 (PST) From: Brian Rogoff To: caml-list@inria.fr Subject: Re: Array interface question In-Reply-To: <199901221921.UAA10085@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis 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