From: anon@anon.org (anon)
Subject: Re: Nested declares, constant size arrays and clarity
Date: Thu, 04 Oct 2007 00:23:22 GMT
Date: 2007-10-04T00:23:22+00:00 [thread overview]
Message-ID: <_nWMi.632696$p47.156954@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: fe1748$it1$1@nemesis.news.tpi.pl
There are basically two ways of dealing with your question.
The First is to create a function or procedure that contains the statements
type MyTypeArray is array (1...sizegiven) of MyType;
MyArray: MyTypeArray;
and then place this and all other routines as children of MXP. In this
case, it is easier to use pointers.
The second way is to create a package for MyType. And place all
funtions and procedures that handles the internal working of
MyType within that package.
You need need routines for:
function: Create_MyType_Array ( Size, ... )
procedure: Destroy_MyType_Array ( MyTypeArray )
function: Retrive_MyTypeArray ( Index, element )
procedure: Store_MyTypeArray ( Index,
element, value, ... )
...
If needed:
procedure: Get ( MyTypeArray, ... )
procedure: Put ( MyTypeArray, ... )
Then the main routine could call these routines.
In <fe1748$it1$1@nemesis.news.tpi.pl>, Mateusz Papiernik <mati@maticomp.net> writes:
>Hey!
>
>I'm starting off with Ada95. I'm having some problems with clarity of my
>solution, which - I think - is not as good as I would like to.
>
>I've got my root procedure in which I read some number from the standard
>input. Then I create an array of MyType with size read before.
>
>procedure mxp is
> ... -- some record type declarations
> ... -- some *functions*
>begin
> ... -- read size
> declare
> type MyTypeArray is array (1...sizegiven) of MyType;
> MyArray: MyTypeArray;
> ... -- some *functions* doing something with newly made array
> begin
> ... -- these function calls
> end;
>end;
>
>The problem is, I don't really like the idea of declaring some functions
>in the root procedure declaration, and some others in nested declare
>section. Due to that I've got function implementations in two places,
>which somehow feels awkward to me.
>
>Is there any way to accomplish the same without that nesting _and_
>without building external module/using OOP/pointers?
>
>Maybe there is a way to define general array type of unknown size, then
>declare functions doing something with it in the topmost declaration
>section, and then only somehow initialise the array with given size?
>
>
>
>Thanks for any advice!
>--
>Mateusz Papiernik, Maticomp Webdesign
>Projektowanie i realizacja witryn WWW
>mati@maticomp.net, http://www.maticomp.net
>"One man can make a difference" - Wilton Knight
prev parent reply other threads:[~2007-10-04 0:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-03 22:58 Nested declares, constant size arrays and clarity Mateusz Papiernik
2007-10-03 23:49 ` Ludovic Brenta
2007-10-04 8:49 ` Mateusz Papiernik
2007-10-04 11:33 ` Ludovic Brenta
2007-10-04 12:45 ` Dmitry A. Kazakov
2007-10-04 13:11 ` Mateusz Papiernik
2007-10-05 5:00 ` Jeffrey R. Carter
2007-10-05 4:58 ` Jeffrey R. Carter
2007-10-05 7:38 ` Dmitry A. Kazakov
2007-10-05 17:08 ` Jeffrey R. Carter
2007-10-05 4:54 ` Jeffrey R. Carter
2007-10-04 0:20 ` Jeffrey R. Carter
2007-10-04 8:51 ` Mateusz Papiernik
2007-10-05 2:45 ` Steve Whalen
2007-10-04 0:23 ` anon [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox