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!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Ada access vs C/C++ pointers and references Date: Thu, 19 Aug 2004 01:21:37 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de nzXxLXrxhxBMFtXYuTgBPQJ/V4hmuQ2xpVqXELj9BU2pHk4QA= User-Agent: Opera M2/7.51 (Win32, build 3798) Xref: g2news1.google.com comp.lang.ada:2824 Date: 2004-08-19T01:21:37+01:00 List-Id: On 18 Aug 2004 15:27:47 -0700, Keith H Duggar wrote: > [re array indexing] > As you can see, method two saves one instruction by storing > and manipulating a memory address directly. In a loop, there is well known optimisation known (for reasons which mystify me) as 'strength reduction', which allows a loop such as: for (i=0;i First, is it correct to say that Ada access types are more > similar to C++ references (T&) than they are to C/C++ > pointers (T*) ? No. Ada access types are very similar to C and C++ pointers, and are typically implemented and used in (almost) exactly the same way. The rough Ada equivalent of C++ references are 'aliased objects'. > Second, does Ada provide any facilities for direct and raw > memory access by memory address and pointer arithmetic? Yes it does. There are standard packages System.Storage_Elements and System.Address_To_Access_Conversions, which provide facilities for converting between access types and addresses, and performing integer arithmetic on addresses, as well as Interfaces.C and Interfaces.C.Pointers which enable Ada programs to access C strings, arrays, and pointers. > Third, if Ada does not provide arithmetic pointers do you > know if this has played any part in acceptance of Ada for > systems programming or efficiency critical applications? I don't know (sorry). > Fourth, have you experienced or can you think of any cases > where pointer arithmetic has helped to solve a problem that > would have been more difficult with Ada access types alone? Not that I can recall. -- Nick Roberts