comp.lang.ada
 help / color / mirror / Atom feed
From: "Dr. Michael Paus" <paus@ib-paus.com>
Subject: Re: C to Ada conversion
Date: Tue, 14 Jan 2003 18:18:50 +0100
Date: 2003-01-14T17:18:52+00:00	[thread overview]
Message-ID: <b01gps$o66$1@news.online.de> (raw)
In-Reply-To: <ELHU9.51517$%n.18940@sccrnsc02>

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





  parent reply	other threads:[~2003-01-14 17:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-13 21:22 C to Ada conversion Mark
2003-01-13 23:14 ` tmoran
2003-01-14  1:27   ` Jeffrey Carter
2003-01-14  3:16     ` tmoran
2003-01-14 12:52       ` Mark
2003-01-14 19:35     ` John R. Strohm
2003-01-14  7:20   ` Martin Dowie
2003-01-14  8:49     ` tmoran
2003-01-14 22:45       ` Martin Dowie
2003-01-14 13:01     ` Mark
2003-01-14 17:18   ` Dr. Michael Paus [this message]
2003-01-14 18:10     ` tmoran
2003-01-14 18:24       ` tmoran
2003-01-14 19:48         ` Dr. Michael Paus
2003-01-14 20:12           ` Vinzent Hoefler
2003-01-14 21:55           ` tmoran
2003-01-16 21:17             ` Mark
2003-01-17  0:10               ` tmoran
2003-01-17  1:09               ` John R. Strohm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox