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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Fri, 24 Sep 2004 15:53:26 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <11b4d.3849$d5.30042@newsb.telia.net> Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Fri, 24 Sep 2004 15:54:36 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-8mTkG0J5sYLF41V+RlJjlc1PEmsgEXEWkMQLbvLO0c/h6I5GAG8YIuTNwWfhvSWL1iIt25aPQ5sgT8j!OSDWi1eRV3zPzqDbb/EcYbgZDUef++n5611PdYOkgxL7fJ3MZzeAK5Drpk8Oc2NdQjSSA+gN0oD7 X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.13 Xref: g2news1.google.com comp.lang.ada:4136 Date: 2004-09-24T15:54:36-05:00 List-Id: "Kevin Cline" wrote in message news:e749549b.0409241112.44f4bc85@posting.google.com... ... > Ok, although it's not readily apparent to me why implicit > instantiations are inherently unsafe. Nor do I believe reference > expressions like > concordance[word] > are inherently unsafe. Storing the reference in a variable that may > outlive the referent is unsafe, but I don't see why this is different > from Ada access types. It isn't different than Ada access types, that's the point. Access types are inherently unsafe and should be avoided when possible. (But not to go overboard, of course.) That's an important design issue when designing reusable libraries. My personal rule is that such libraries should not contain access types of any kind in their specification unless they are doing something that requires dynamic management of objects. (That's rather rare.) In Ada, there is no need to use access types to get OOP or to get objects sized at runtime -- those uses are common in other languages. Ada goes to fairly great lengths to try to avoid dangling pointers (the dreaded accessibility rules), so access types in Ada are a bit safer than those in some other languages. But that doesn't make them safe by any means. In this particular case, the access would have roughly the same erroneous use rules as a cursor does, which wouldn't be that awful. But it wouldn't be a very good example of Ada design, because the library would return an access to a data structure that is managed by other code -- which cannot know whether any accesses remain -- so it would be impossible to be safe. (I'm intending an implementation of the containers library that will try to detect dangling cursors, so there will be little chance of building buggy code with it.) Randy.