From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA11791; Wed, 14 Nov 2001 14:48:25 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA11148 for caml-list@pauillac.inria.fr; Wed, 14 Nov 2001 14:48:24 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA06074 for ; Wed, 14 Nov 2001 10:53:23 +0100 (MET) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAE9rL513094 for ; Wed, 14 Nov 2001 10:53:22 +0100 (MET) Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) id KAA18098; Wed, 14 Nov 2001 10:52:57 +0100 Date: Wed, 14 Nov 2001 10:52:57 +0100 From: Markus Mottl To: "Marcin 'Qrczak' Kowalczyk" Cc: caml-list@inria.fr Subject: Re: [Caml-list] A few questions regarding the compiler Message-ID: <20011114105257.B17604@fichte.ai.univie.ac.at> References: <9smdf7$511$1@qrnik.zagroda> <9ssfsl$fa4$1@qrnik.zagroda> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from qrczak@knm.org.pl on Wed, Nov 14, 2001 at 03:03:57 +0000 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 14 Nov 2001, Marcin 'Qrczak' Kowalczyk wrote: > I guess that it's fine to initialize an array of non-floats with > 'Obj.magic 0' even if the type doesn't have nullary constructors, > provided that I overwrite elements with valid objects before use? Yes, this is safe for non-float arrays. The GC will only interpret some array element as a pointer to follow if it is not tagged as integer (or nullary constructor, which is the same representation). I abuse this "feature" in my "Res"-module to implement automatically resizing arrays. > I don't always have a proper element at hand. Is it true that the > Array module cares to always find a valid element for initialization > only because of float arrays? There is no function that allows you to create an array without passing an initial element in the Array-module. It would be nice if there were a function that allows one to create uninitialized, unboxed float arrays. This is easy to implement and could be useful for efficiency purposes in some occasions. It's, of course, not possible for other kinds of arrays, because the memory region might contain things that look like a pointer to the GC. Btw., wouldn't it be possible (or is this actually implemented - haven't looked) that the GC allocates arrays of integers always within the same region of memory? Then it could reuse this region as a pool for creating uninitialized integer arrays. Only if there is not enough memory, more would have to be allocated and initialized. > Why are small arrays and large arrays treated differently? I think this is part of the GC-strategy to gain efficiency. The heuristics is that large arrays (or other large chunks of memory) are not likely to be short-lived. I hope my explanations were not too far from the truth... ;) Regards, Markus Mottl -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr