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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bc7fae210b5e1392 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: how do i include 111111 in an enumaration type ? Date: 1999/10/13 Message-ID: <7u28tv$rph$1@nnrp1.deja.com>#1/1 X-Deja-AN: 536254770 References: <7tsq3o$92p$1@minus.oleane.net> <38021792_4@news1.prserv.net> <7ttuvt$ssb$1@minus.oleane.net> <38033f0b_3@news1.prserv.net> <7tvpd6$1mg$1@nnrp1.deja.com> <380485d2_1@news1.prserv.net> X-Http-Proxy: 1.0 x31.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Oct 13 15:36:33 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-10-13T00:00:00+00:00 List-Id: In article <380485d2_1@news1.prserv.net>, "Matthew Heaney" wrote: > In article , lutz@iks-jena.de > (Lutz Donnerhacke) wrote: > > > From reading the Rationale and Reference Manual, the novice (like > > me) can not deduce, that this 'Unchecked_'-Package is required for > > normal usage. > > Unchecked_Deallocation is not required for normal usage. Well, that depends on what you define as "normal". > There are idioms for implementing abstractions that use the heap or > some form of indirection. Basically, you want to hide all of that > from the client. True. But you are talking perspective. That doesn't let Lutz off the hook if he happens to be *writing* the code that "clients" are using. My general idom for this is: o Don't worry about it if the allocations only happen once and you are only running on "heavy" OS's that clean up allocated memory when the program exits (EG: Unix, Win32). o If you allocate memory for temporary processing in a routine, make sure to (unchecked_)deallocte it before you return. o As a special case of the above, if you need to do a lot of allocations in a routine that get cleaned up at the end, and know the maximum total memory size you will ever need, consider creating an access type in the routine and specifying a storage pool size for it. All objects allocated into values of that access type will then get automagicly deallocted when the routine ends. o If you allocate memory for non-transient use in a routine, keep track of it in some kind of "cookie" object (typically as part of another private object that is already passed in), and provide a "cleanup" routine to the user. Both routines should be copiously commented as to when "cleanup" needs to be called. o As a speicial case of the above, if the allocation happens as part of an initialization, consider using a controlled type (derived from Ada.Finialization.Controlled and .Limited_Controled), as the calls to initialize and cleanup will be made automaticly. o Avoid returning a pointer to allocted memory to the client, for them to clean up manually themselves. (This was the whole of Matt's point, I believe). That's a truly ugly interface. In fact it gives "interface" a bad name. -- T.E.D. Sent via Deja.com http://www.deja.com/ Before you buy.