From: John M. S. <sk...@oz...> - 2003-06-21 23:52:08
|
Yamagata Yoriyuki wrote: > From: Alan Post <ap...@re...> > Subject: [Ocaml-lib-devel] Re: Array interface > Date: Fri, 20 Jun 2003 23:56:25 +0000 (UTC) > > >>What is under discussion is what to put in the "empty" slots of the >>newly doubled array, ocaml having no "null" or "undef" value to stuff >>in them. >> > > I do not understand the motive of Dynarray, Variable length array with automatic efficient resizing. It needs to allocate more store than the number of slots actually needed to minimise reallocation on extension of the array, and allow contraction without necessarily reallocating. So there are some slots of the underlying array that are unused. The problem is how to fool the garbage collector without a dummy object to put in the unused slots. The client may not be able to construct an object of the right type easily, and copying a real element may create references that prevent the collector removing an object -- unless the design carefully refills unused slots with the value of a used slot -- and destroys the array completely when no slots are used. Therefore, there is no really good design 'in ocaml': Dynarray is really a system primitive. Hmmm.. it was said a C implementation should use VALUE macro not integer 0. A small C interface will make that available as a universal NULL value? I guess this is a C null pointer: ie, an address the collector will leave alone, rather than an integer the collector will leave alone? -- John Max Skaller, mailto:sk...@oz... snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 |