What I want to do is make a type that, among other things, controls values that other parts of the code pass to it. This is part of a menu system, and would extend an abstract type and itself be abstract. What I would like to do is store an access. Simple enough.
type Adjuster is abstract new Menu_Item with record --other fields Value : access Integer; end record;
Question is, how can I make this extendable to other types? I'd prefer that to having to define Integer_Adjuster, Float_Adjuster, etc. I kinda thought of using generics:
generic type T; type T_Access is access T; type Adjuster is abstract new Menu_Item with record --other fields Value : T_Access; end record;
But this tells me that there's a semicolon missing on the "type Adjuster..." line, presumably because Ada/Gnat can't figure out whether the line is declaring a type that should be included in the generic portion or this is the type the generic portion should be applied to. I think the only way to do this would be to actually make an Adjuster package and make that generic (but I'd rather not...).
I also toyed with the idea storing an Address rather than an Access, since Ada doesn't care what kind of Address it is:
type Adjuster is abstract new Menu_Item with record --other fields Value : System.Address end record;
But first of all I don't know enough about Addresses to determine whether this will work or how it would work (do you assign to Value.all..?) and second, being able to store a [shrugs shoulders] really feels like the kind of thing that Ada is designed to not be able to do.
I'm kinda out of ideas. Any help would be appreciated.