comp.lang.ada
 help / color / mirror / Atom feed
From: Mario Amado Alves <maa@di.fct.unl.pt>
To: "comp.lang.ada@list.deja.com" <comp.lang.ada@list.deja.com>
Subject: Generic package array parameter
Date: 1999/11/12
Date: 1999-11-12T00:00:00+00:00	[thread overview]
Message-ID: <Pine.LNX.4.10.9911121752180.11396-100000@lexis.di.fct.unl.pt> (raw)
In-Reply-To: 382255CE.F5CB679A@erols.com

I am trying to rewrite

generic
  type X is (<>);
  type Y is (<>);
  Table: array(X, Y) of X;
package Foo is
...

in order to circuvent the 'anonymous array definition not allowed here'
constraint. I tried

generic
  type X is (<>);
  type Y is (<>);
  Table: Table_Type;
package Foo is
  type Table_Type is array(X, Y) of X;
...

and of course got '"Table_Type" is undefined'. Then I tried

generic
  type X is (<>);
  type Y is (<>);
  type Table_Type is array(X, Y) of X;
  Table: Table_Type;
package Foo is
...

which of course works, but is odd, and requires an equally odd
instantiation:

type My_X is ...;
type My_Y is ...;
type My_Table_Type is array(My_X, My_Y) of My_X;
My_Table: My_Table_Type := (...);
package My_Foo is new Foo(My_X, My_Y, My_Table_Type, My_Table);
...

This works, but is ugly and stupid. Is there a smart way to rewrite it?

(I feel I am again on the verge of giving up the Ada generic programming
idiom. What is this Ada thing with anonymous array types?)

Thanks.

| | |,| | | | |RuaFrancTaborda24RcD 2815-249CharnecaCaparica 351+212976751
| |M|A|R|I|O| |                                              mob 219354005
| |A|M|A|D|O| |DepartmentoInformaticFCT/UNL 2825-114Caparica 351+212958536
| |A|L|V|E|S| |                                              fax 212948541
| | | | | | | |               maa@di.fct.unl.pt              FCT 212948300




 Sent via Deja.com http://www.deja.com/
 Before you buy.




  parent reply	other threads:[~1999-11-12  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-04  0:00 HELP - MAC compilation of an Ada program William A Whitaker
1999-11-05  0:00 ` James E. Hopper
1999-11-05  0:00 ` Robert Dewar
1999-11-12  0:00 ` Mario Amado Alves [this message]
1999-11-12  0:00   ` Generic package array parameter Matthew Heaney
1999-11-13  0:00     ` Robert A Duff
1999-11-23  0:00       ` Mario Amado Alves
1999-11-23  0:00         ` Matthew Heaney
1999-11-12  0:00   ` Tucker Taft
replies disabled

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