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,c50f57c0c29b391b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!xmission!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: memory management Date: 28 May 2005 07:44:16 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1131064.rs72P29t4t@yahoo.com> <1226363.QsRZW1KHie@linux1.krischik.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1117280656 19969 192.74.137.71 (28 May 2005 11:44:16 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 28 May 2005 11:44:16 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:11190 Date: 2005-05-28T07:44:16-04:00 List-Id: Martin Krischik writes: > Robert A Duff wrote: > > > alex goldman writes: > > > >> As I understood from reading the Ada tutorial for C/C++ programmers, > >> "access" is essentially like C++ smart pointer, > > > > No, Ada access types are just pointers -- no "smarts". > > To make something like smart pointers, you can use > > controlled types. > > No again - any paricular Ada implementation is free to implement access > types as they see fit. With GNAT an access may consist of an pointer to the > data and a pointer to a dope vector: That's what I call a "fat pointer". Still just a pointer (as opposed to a smart pointer). When I say "pointer", I don't mean it has to be implemented as a single machine address. It could be an offset from some known base address, an index into an array, or (as you say) a fat pointer -- among other things. The same is true of pointers in C and C++ -- an implementation is free to implement pointers as something other than a machine address. In fact, if a C compiler wishes to check array bounds, it pretty much *has* to use fat pointers. I know of one C compiler that did just that. My point is that "pointer" is not synonymous with "single machine address", even in C. By the way, I believe the fat pointers used by GNAT are an option -- there's some way to tell it to use thin pointers for access-to-array. GNAT uses fat pointers (by default) only when the designated type is an array, or when the designated type is unknown to the compiler. Access-to-record, which is far more common, uses thin pointers. I don't know of any Ada implementation besides GNAT that uses fat pointers at all. > http://en.wikipedia.org/wiki/Dope_vector > Remeber that an Ada compiler may also implement garbage collection. Yes. That would typically *not* involve smart pointers. - Bob