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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d0fa2610a6bea4ec X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!out02b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!green.octanews.net!news-out.octanews.net!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Nested declares, constant size arrays and clarity Reply-To: anon@anon.org (anon) References: X-Newsreader: IBM NewsReader/2 2.0 Message-ID: <_nWMi.632696$p47.156954@bgtnsc04-news.ops.worldnet.att.net> Date: Thu, 04 Oct 2007 00:23:22 GMT NNTP-Posting-Host: 12.64.216.140 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1191457402 12.64.216.140 (Thu, 04 Oct 2007 00:23:22 GMT) NNTP-Posting-Date: Thu, 04 Oct 2007 00:23:22 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:2288 Date: 2007-10-04T00:23:22+00:00 List-Id: 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 , Mateusz Papiernik 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