From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, LOTS_OF_MONEY,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5653f0bd43045b85 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: garbage collection Date: 1999/08/21 Message-ID: <7pm95n$j0l$1@nnrp1.deja.com>#1/1 X-Deja-AN: 515468326 References: X-Http-Proxy: 1.0 x25.deja.com:80 (Squid/1.1.22) for client 166.72.82.184 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Sat Aug 21 13:22:04 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-08-21T00:00:00+00:00 List-Id: In article , tmoran@bix.com wrote: > > Just to clarify, most implementations don't actually do > > this. > Why? Is an implementation not easy, efficient, > and predictable? Easy: fairly so, look at System.Pool_Local in the GNAT sources (s-pooloc.ads). Not that complex. The body is 189 lines, perhaps only 60 lines or so of actual code. Predictable: sure Efficient: there's the rub, there is significant overhead from arranging for the automatic release, both in space and time. We found that most existing code does NOT assume this automatic release, and it clearly makes no sense to use this pool by default if the program does all its own deallocation. > And of course overidable by the user simply by raising the > level where the access type is declared. > It seems undesirable to have to specify a number, big enough, but > not too big, for the amount of storage needed when you merely want > to get automatic deallocation. No, that's not the way to do it (using Storage_Size). Only use a Storage_Size where it really does make sense to allocate in a fixed length area on the stack. Instead use a storage pool. If you are using GNAT, just do for this_access_type'Storage_Pool use System.Pool_Local.Unbounded_Reclaim_Pool; and of course do a "with" of System.Pool_Local. If you are using some other compiler that does not provide this very useful capability, then you need to write your own storage pool implementation (the one with GNAT may work, but you can't assume that library routines supplied with GNAT will work unchanged with other compilers (*) since they may depend on GNAT specific features -- I don't know if this one does or not). Robert Dewar Ada Core Technologies (*) People sometimes make the mistake of assuming that because the GNAT runtime is written in Ada, it can automatically be used with other compilers. Sometimes this is the case (indeed one other vendor was routinely supplying some of the GNAT math routines for a while, to plug holes in their own run-time, they may still do this, I don't know ...) But on the other hand, sales folks for that same vendor were telling people: "DOn't worry about the information systems annex, we don't provide it, but if you need it, you can just pick up the GNAT routines and use them with our compiler." Unfortunately that is definitely not the case. In the first place, the underlying compiler must support 18-digit decimal scaled arithmetic. Secondly, the implementation relies on GNAT specific stuff, e.g. procedure Divide (Dividend : in Dividend_Type; Divisor : in Divisor_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type) is -- We have a nested procedure that is the actual -- intrinsic divide. -- This is required because in the current RM, Divide -- itself does -- not have convention Intrinsic. procedure Divide (Dividend : in Dividend_Type; Divisor : in Divisor_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type); pragma Import (Intrinsic, Divide); begin Divide (Dividend, Divisor, Quotient, Remainder); end Divide; Now it would be possible to implement a non-intrinsic divide, but it would be gruesomely inefficient. This is simply a divide operation, and really needs to be specialized by the compilers code generator. Trying to do this with portable Ada is just at the wrong level! Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.