comp.lang.ada
 help / color / mirror / Atom feed
* Heterogenous array
@ 2004-03-01  1:53 Björn Persson
  2004-03-01  2:22 ` Steve
  2004-03-01 16:48 ` Robert I. Eachus
  0 siblings, 2 replies; 11+ messages in thread
From: Björn Persson @ 2004-03-01  1:53 UTC (permalink / raw)


I need an array type that can hold elements of different types. My 
current attempt (somewhat simplified) is below. My question is, is there 
a way to do this without pointers?

    type T_Param_Type is (Int, Str);
    type Parameter_Definition(Param_Type : T_Param_Type) is record
       Name : A_Bounded_String_Type;
       case Param_Type is
          when Int =>
             Min : Integer;
             Max : Integer;
             Int_Value : Integer;
          when Str =>
             Str_Value : Ada.Strings.Unbounded.Unbounded_String;
       end case;
    end record;
    type Parameter_Definition_Pointer is access Parameter_Definition;
    type Parameter_Spec is array(Positive range <>) of
                           Parameter_Definition_Pointer;

"array(Positive range <>) of Parameter_Definition" gave me the error 
"unconstrained element type in array declaration". I also tried a tagged 
type with subtypes and "array(Positive range <>) of 
Parameter_Definition'Class", and got the same error.

This isn't really a dynamic data structure so I feel that pointers 
shouldn't be necessary. Any ideas?

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




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

end of thread, other threads:[~2004-03-03 17:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-01  1:53 Heterogenous array Björn Persson
2004-03-01  2:22 ` Steve
2004-03-01 16:48 ` Robert I. Eachus
2004-03-01 22:01   ` Björn Persson
2004-03-01 23:29     ` Randy Brukardt
2004-03-02  2:56       ` Robert I. Eachus
2004-03-02  3:13     ` Steve
2004-03-02 22:29       ` Björn Persson
2004-03-03  9:43         ` Jean-Pierre Rosen
2004-03-03 14:44           ` Björn Persson
2004-03-03 17:52             ` Jean-Pierre Rosen

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