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,FREEMAIL_FROM, HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc772,b30bd69fa8f63cb2 X-Google-Attributes: gidfc772,public X-Google-Thread: 103376,b30bd69fa8f63cb2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-14 17:41:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uwm.edu!rpi!not-for-mail From: James Rogers Newsgroups: comp.lang.ada,comp.lang.c++.moderated Subject: Re: C bug of the day Date: 14 Jun 2003 20:43:57 -0400 Organization: AT&T Worldnet Sender: cppmods@netlab.cs.rpi.edu Message-ID: References: <1054751321.434656@master.nyc.kbcfp.com> NNTP-Posting-Host: netlab.cs.rpi.edu X-Original-Date: Sat, 14 Jun 2003 14:55:40 GMT X-Submission-Address: c++-submit@netlab.cs.rpi.edu X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated iQBVAwUAPuvBSkHMCo9UcraBAQHWhQIAqcxOwip8ce3t87NvO0m+cK/In4rhKeVI w/SOinR+33ZkGRaVW9//uKtK2eMv4/QLbhPmaR+h8q6PiLnxBs85LQ== =oUeY Xref: archiver1.google.com comp.lang.ada:39188 comp.lang.c++.moderated:68372 Date: 2003-06-14T20:43:57-04:00 List-Id: kanze@gabi-soft.fr wrote in news:d6652001.0306130749.5d9cd084@posting.google.com: > James Rogers wrote in message > news:... > > That said, like C++, Ada does not prohibit garbage collection. > > Perhaps a more relevant question would be: do comment implementations > have it? Or is it used? (But as others have mentionned, it may not > be used because typical Ada applications are in domains where it is > NOT appropriate.) > The only implementation I am aware of was the no longer supported version of GNAT that targeted the JVM. Garbage collection was supported because the JVM requires it. Typical Ada applications are in real time safety critical domains. Garbage collection is not heavily used in those domains. As others have noted, some domains such as avionics systems do not even use dynamic memory allocation other than stack-based allocation. What all Ada compilers do support is the creation and use of storage pools. Quoting from the Ada language reference manual: "Each access-to-object type has an associated storage pool. The storage allocated by an allocator comes from the pool; instances of Unchecked_Deallocation return storage to the pool. Several access types can share the same pool." "A storage pool is a variable of a type in the class rooted at Root_Storage_Pool, which is an abstract limited controlled type. By default, the implementation chooses a standard storage pool for each access type. The user may define new pool types, and may override the choice of pool for an access type by specifying Storage_Pool for the type." When you define a storage pool you also must define implementations for the abstract procedures Allocate and Deallocate. When you define an access type you can define which storage pool instances of that type uses. All allocations and deallocations relating to instances of that access type use the specified storage pool and are subject to the allocation and deallocation rules of that storage pool. This is how you would define Ada equivalents to smart pointers or even garbage collection. I like the idea that you can create special characteristics for some access types without requiring that special behavior for all access types. Jim Rogers [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ] [ about comp.lang.c++.moderated. First time posters: do this! ]