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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,83d2d63f98e99c58 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-14 09:18:56 PST From: "Dr. Michael Paus" Newsgroups: comp.lang.ada Subject: Re: C to Ada conversion Date: Tue, 14 Jan 2003 18:18:50 +0100 Organization: 1&1 Internet AG Message-ID: References: NNTP-Posting-Host: p5083059c.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.online.de 1042564732 24774 80.131.5.156 (14 Jan 2003 17:18:52 GMT) X-Complaints-To: abuse@online.de NNTP-Posting-Date: 14 Jan 2003 17:18:52 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en In-Reply-To: Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!feed.news.nacamar.de!news.belwue.de!news.uni-ulm.de!rz.uni-karlsruhe.de!schlund.de!news.online.de!not-for-mail Xref: archiver1.google.com comp.lang.ada:33007 Date: 2003-01-14T17:18:52+00:00 List-Id: tmoran@acm.org wrote: >>Interested in doing some benchmarking in Ada. ... convert > > See below > >>I'm also curious on how Ada allocates and deallocates objects > > There is an alloc(new)/free mechanism but usually it's more efficient, > as well as easier and less error prone, to just let the compiler allocate > things stack-wise. See matrix "Ac" below. It's allocated automatically, > and deallocated automatically. (Actually, since it's never used here, > one hopes a good compiler doesn't bother generating any code for it.) [...] I hope nobody will be using this Ada code for any serious purpose. As a quick and dirty conversion for some benchmark it is certainly ok but otherwise it is very dangerous because it does not take into account that in Ada the index range of arrays does not necessarly start with 1 (or 0 as in C). A general purpose matrix package should be able to cope with the situation that the index range could be anything as long as the involved matrices are compatibel in size. Otherwise it would be difficult to use slices of arrays for example. If someone uses the example here with a definition like this CPCTSzInv: Matrices(0 .. Rs - 1, 0 .. Rs - 1); -- (C*P*CT+Sz)**-1 with the other matrix unchanged the compiler won't complain but the result will be a constraint_error at run-time. In C you simply don't have this specific Ada problem because an array by definition has an index range starting with 0 and there is no good reason why the inversion should not be possible in this case. In practice you often have the need to mix arrays which have compatibel sizes but not the same index range. Just my 2 (Euro-)cents Michael