comp.lang.ada
 help / color / mirror / Atom feed
* Newbe Q: generic array not working OK
@ 2000-03-12  0:00 Erik Pessers
  2000-03-13  0:00 ` Jeffrey D. Cherry
  2000-03-13  0:00 ` swhalen
  0 siblings, 2 replies; 5+ messages in thread
From: Erik Pessers @ 2000-03-12  0:00 UTC (permalink / 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>






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-03-15  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-12  0:00 Newbe Q: generic array not working OK Erik Pessers
2000-03-13  0:00 ` Jeffrey D. Cherry
2000-03-14  0:00   ` Ehud Lamm
2000-03-15  0:00     ` Tucker Taft
2000-03-13  0:00 ` swhalen

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