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,b860b4e8d00468ef X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news2.telebyte.nl!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada access vs C/C++ pointers and references Date: Thu, 19 Aug 2004 10:11:01 +0200 Message-ID: <1g8jhtbcbk0e5$.19jsic6idgcet.dlg@40tude.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de CIr7/QoPBd0ObpheWatr4w0lCf01n0WM3USw2JmA83qOJG5Go= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:2845 Date: 2004-08-19T10:11:01+02:00 List-Id: On 18 Aug 2004 15:27:47 -0700, Keith H Duggar wrote: > First, is it correct to say that Ada access types ore more > similar to C++ references (T&) than they are to C/C++ > pointers (T*) ? I wouldn't say so. References in C++ have three major uses: 1. Parameter passing mode specification: T& Foo (T& X); 2. Aliasing: T& X = *Y [123].Z ()->Baz; 3. Mix-in: class Y { T& X; In Ada only 3 is customary implemented using access types: 1. Some types are always by-copy, some are always by-reference, and for the rest the compiler is free to choose the best. 2. Aliasing is achieved by renaming: X : T renames Y(123).Z().Baz.all; 3. Only for mix-in one usually uses anonymous access types: type Y (X : access T) is ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de