comp.lang.ada
 help / color / mirror / Atom feed
From: Erik Pessers <sky84415@skynet.be>
Subject: Newbe Q: generic array not working OK
Date: 2000/03/12
Date: 2000-03-12T14:49:39+00:00	[thread overview]
Message-ID: <38CBAE60.621F6A2D@skynet.be> (raw)

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  <Erik.Pessers@ACM.ORG>






             reply	other threads:[~2000-03-12  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-12  0:00 Erik Pessers [this message]
2000-03-13  0:00 ` Newbe Q: generic array not working OK Jeffrey D. Cherry
2000-03-14  0:00   ` Ehud Lamm
2000-03-15  0:00     ` Tucker Taft
2000-03-13  0:00 ` swhalen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox