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,931285576c2f2928 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-21 03:21:18 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!elnk-atl-nf1!newsfeed.earthlink.net!bigfeed2.bellsouth.net!bigfeed.bellsouth.net!bignumb.bellsouth.net!news.bellsouth.net!bignews5.bellsouth.net.POSTED!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada References: Subject: Re: passing an array to a generic function MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: X-Trace: ldjgbllpbapjglppdbdpiflmbcekedmfhojhikkbagflhcbomkjanlgpfbaemjohacmjijfmbljakhllkoemfgboakbmancknmbldfmhfomedbcmbgjhmnnmpgicogmaefnkeklllmcdfoklcmibnkoacmafknha NNTP-Posting-Date: Fri, 21 Nov 2003 06:18:10 EST Date: Fri, 21 Nov 2003 05:20:52 -0600 Xref: archiver1.google.com comp.lang.ada:2793 Date: 2003-11-21T05:20:52-06:00 List-Id: You need to understand and act on the messages the compiler sends you. Accordingly, the following code will compile: generic type Index is (<>); type Item is private; type Arr is array(Index) of Item; with function "="(I1,I2 : Item) return Boolean is <>; function Filter_Array(A: Arr) return Arr; type Index is new Integer range 1 .. 23; type Item is new Character; type Arr is Array(Index) of Item; function Filter_String is new Filter_Array(Index,Item,Arr,"="); However. when you declare types as new "some other type", you're creating new types that are distinct from the "some other type." Therefore, if as the name of your instantiation implies, you intend to pass objects of type string to it, you would do better to do this: generic type Index is (<>); type Item is private; type Arr is array(Index) of Item; with function "="(I1,I2 : Item) return Boolean is <>; function Filter_Array(A: Arr) return Arr; subtype Index is Integer range 1 .. 23; subtype Arr is String (Index); function Filter_String is new Filter_Array(Index, Character, Arr, "="); "Mr. J." wrote in message news:fc116fae.0311210231.d4a9515@posting.google.com... > hi, > > this is my generic function: > > generic > type Index is (<>); > type Item is private; > type Arr is array(Index range <>) of Item; > with function "="(I1,I2 : Item) return Boolean is <>; > > function Filter_Array(A: Arr) return Arr; > > Now, I wanna write a create a Filter_String function according to it: > > type Index is new Integer; > type Item is new Character; > type Arr is Array(1..23) of character; > > function Filter_String is new Filter_Array(Index,Item,Arr,"="); > > As U all experts guessed it won't compile, my question is how to pass > the array of character to my new function ? > > 10x, > J. > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada-france.org > http://www.ada-france.org/mailman/listinfo/comp.lang.ada > >