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,86cefd3e84a541f2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-18 14:35:51 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.online.be!zur.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Parallel Merge Sort X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C718050.7CE63E36@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <0sgb8.36$hk2.28284109@newssvr14.news.prodigy.com> Mime-Version: 1.0 Date: Mon, 18 Feb 2002 22:29:36 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:20115 Date: 2002-02-18T22:29:36+00:00 List-Id: "R. Stegers" wrote: > > Maybe someone can help me solve one final little issue. > > The parallel Merge Sort works fine now. But when I want to use it I cannot > directly declare for example an integer array: > > package IntSort is new SORT_PACKAGE(integer, compareInt); > use IntSort; > > -- This declaration does not work when I want to use ar as a parameter in > a call to Sort. > ar : integer array(1..3); This is invalid Ada. You might be trying to say Ar : array (1 .. 3) of Integer; Now Ar is of an anonymous array type. Since procedure Sort requires a variable of type Element_Array, obviously this variable won't work. > > -- Instead I have to use this. > ar : IntSort.element_array(1.. 3); This Ar has the correct type, which is why it works. If your package were defined as generic type Element is private; type Element_Array is array (Positive range <>) of Element; ... Then you could write type Integer_Array is array (Positive range <>) of Integer; package Sort is new Sort_Package (Element => Integer, Element_Array => Integer_Array, ...); Ar : Integer_Array (1 .. 3); ... Sort.Sort (Inarray => Ar); Even better might be generic type Element is private; type Index is (<>); type Element_Array is array (Index range <>) of Element; ... Then your instantiation would read package Sort is new Sort_Package (Element => Integer, Index => Positive, Element_Array => Integer_Array); However, I suspect you would have to modify most of your use of indices in Sort_Package if you did this. -- Jeffrey Carter