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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ff52d623df1ca1d6,start X-Google-Attributes: gid103376,public From: Erik Pessers Subject: Newbe Q: generic array not working OK Date: 2000/03/12 Message-ID: <38CBAE60.621F6A2D@skynet.be>#1/1 X-Deja-AN: 596448044 Content-Transfer-Encoding: 7bit X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@skynet.be X-Trace: news0.skynet.be 952872579 30064 194.78.230.86 (12 Mar 2000 14:49:39 GMT) Organization: Belgacom Skynet SA/NV Mime-Version: 1.0 Reply-To: Erik.Pessers@ACM.Org NNTP-Posting-Date: 12 Mar 2000 14:49:39 GMT Newsgroups: comp.lang.ada Date: 2000-03-12T14:49:39+00:00 List-Id: Hi, Trying to better understand the "generic" concept, I did stumble over a problem I do not fully understand (most propably because I'm new to using Ada, coming from a Pascal/Modula-2 background). I get errors when compiling the attached piece of code on a Linux (Debian 2.2.10) PC using GNAT 3.11: gnatgcc -c test.adb test.adb:4:48: expect unconstrained array in instantiation of "Vec" test.adb:4:48: instantiation abandoned gnatmake: "test.adb" compilation error Code is in fact taken from John Barnes book./ Please tell me what point I'm missing? TIA. t.ads : package t is generic type Index is (<>) ; type Item is private ; type Vec is array (Index range <>) of Item ; with function "+" (x,y : Item) return Item ; function Apply (a : vec) return Item ; end t ; t.adb : package body t is function Apply (a : vec) return Item is r : Item := A(A'First) ; begin return (r) ; end Apply ; end t ; test.adb: with t ; procedure test is type Vec is array (Integer range 1..6) of Float ; function Sum is new t.Apply (Integer, Float, Vec, "+") ; begin null ; end test ; -- Erik Pessers