comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: C to Ada : a piece of code
Date: 1996/09/09
Date: 1996-09-09T00:00:00+00:00	[thread overview]
Message-ID: <01bb9e40$d0312d80$348371a5@dhoossr.iquest.com> (raw)
In-Reply-To: JSA.96Sep8202531@alexandria


Jon S Anthony <jsa@alexandria> wrote in article
<JSA.96Sep8202531@alexandria>...
> In article <01bb9d61$537fe5e0$2b8371a5@dhoossr.iquest.com> "David C.
Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:
> Well, sure.  I guess I should have included an ellipsis after the end
> loop to show the rest of whatever you might want to do.  Also, there's
> no reason why you couldn't just eliminate the declare block by means
> of a subprogram.  As for not using malloc in this case, I see that as
> a real good thing - no memory management to deal with.  As far as
> calloc, you can just add an initializer (for unknown reasons since he
> just sets all the values anyway).  And you can always pass such an
> array around via parameters or function returns - again no need for
> the allocator.
Please explain to me how, (since the size of the array required is acquired
through standard input) if dynamic memory allocation is not used, you're
going to acquire static memory of the specified size, to which access can
be safely passed without it's going out of scope.  In fact, gnat has gotten
smarter than, say, VADS, in this regard, in that it will tell you when
you're passing access to memory that would be out of scope.

> Shrug.  It uglifies the dynamic array allocation (needing a -1).  He
> said _equivalent_ Ada, not "identical" word for word translation.  In
> fact, an identical word for word translation of this particular case
> is just bad Ada.

The trade off, (in those frequent cases where 0-based indexing is more
appropriate) is the one-time ugliness of the allocation, vs. the every time
ugliness of the references which need something like Vect'FIRST subtracted
during index computation.

-- 
David C. Hoos, Sr.,
http://www.dbhwww.com
http://www.ada95.com

> 




  reply	other threads:[~1996-09-09  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-07  0:00 C to Ada : a piece of code Grave Xavier
1996-09-07  0:00 ` Robert A Duff
1996-09-07  0:00 ` David C. Hoos, Sr.
1996-09-08  0:00 ` Jon S Anthony
1996-09-08  0:00   ` David C. Hoos, Sr.
1996-09-09  0:00     ` nasser
1996-09-09  0:00   ` Jon S Anthony
1996-09-09  0:00     ` David C. Hoos, Sr. [this message]
1996-09-09  0:00       ` Robert Dewar
1996-09-10  0:00         ` Geert Bosch
1996-09-11  0:00           ` Robert Dewar
1996-09-11  0:00             ` Jonas Nygren
1996-09-13  0:00             ` Geert Bosch
1996-09-14  0:00               ` Robert Dewar
1996-09-11  0:00           ` Robert Dewar
1996-09-13  0:00             ` Geert Bosch
1996-09-14  0:00               ` Robert Dewar
1996-09-09  0:00       ` John G. Volan
1996-09-10  0:00 ` Jon S Anthony
replies disabled

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