From: Bardur A. <sp...@sc...> - 2005-03-06 05:49:37
|
Alain Frisch wrote: > Bardur Arantsson wrote: > >> I think there *might* be a problem with doing this. I don't remember >> the details right now, but I do remember being quite sure it was >> actually necessary to fill up using NULLs instead of copies. >> (Obviously it had something to do with the extra references causing >> objects to hang around for longer than necessary). > > > I've thought about that, and I don't see any problem. Since the "used > part" of the array is read-only, I don't see any problem. If the value > used as an initializer is referenced through any cell of the array, then > the first cell - which still contain the same value - is also referenced > as well. > Yup, you're certainly right about that. The only potential "problem" is in situations like with VList.map where you have references *after* the last_used: |---| \ |----| | . | |-- not x | .. | | . | / | .. | L-> | x | ---map---> | x' | <- L' | x | | ?? | | x | | ?? | |---| |----| Since the reference to L may be dropped later (and there are none before position L), you certainly don't want to set '??' to x; you want to set them to x'. So the "problem" is just that you have to be a bit more careful about initializers when copying the array. But since Array.create will actually "force" you to think about the initializer should be, it shouldn't be a problem in practise. (And besides, I only need to get the code right *once* :)) Thanks for the help, I'll remove all the NULL stuff some time today and make a new snapshot. -- Bardur Arantsson <ba...@im...> <ba...@sc...> It hovered above the ground, much in the way that bricks don't. Douglas Adams, 'Hitchiker's Guide to the Galaxy' |