From: Brian H. <bri...@ql...> - 2003-06-17 15:09:36
|
On Tue, 17 Jun 2003, John Skaller wrote: > I finally managed to get hold of the archive. > If you want to make me a developer I can contribute to the documentation. > > Comments. DynArray.make size null: makes an array of length zero, > with size element slots initialised by null. > > Can't you initialise the empty slots with Obj.magic(0)? No. What if it's an array of floats, which is unboxed? > I don't want to put an element here. I may not have a > convenient default, and even if I do it is going > to kill performance compared to an integer, since > there will be a bogus pointer for the collector to > chase down. If you don't have a convient default, use a 'a option Dynarray.t. That gives you a convient default- None. I didn't want to always use options in the array, because in many cases you don't need them, cases where there are sane, or at least usable default values (0, nan, "", false, etc). Note: in the current API there is no way to get access to an element with a null value. So you don't ever have to worry about distinguishing null values from sensible values. So it's still safe if the null value would otherwise have meaning. > > Also, I haven't checked the collector header, > but isn't there a count field that can be > used for the count without compromising the > allocator's knowledge of the length of a block? > [The size may be needed for disposal and/or movement > on compaction] If there is, the store can be > totally uninitialised, which is even more efficient. I haven't checked, but the idea of using uninitialized memory with a garbage collector makes me nervous. Brian |