Access-to-variable designates constant when trying to pass a pointer to vector element
This question is a follow-up to How to get access to a record field .
The more complex (now) code involves binding a whole vector of records. Something along the lines below:
type Tag is record
Field : String := "value";
end record;
type Tag_Access is access all Tag;
package Tags_Vectors is new Indefinite_Vectors
(Index_Type => Positive,
Element_Type => Wheel_Tag);
procedure Bind_Tag (T : in out Tag_Access; Stmt : Gnade.Statement) is
begin
Gnade.Bind_Text (Stmt, T.Field'Address, T.Field'Length);
end Bind_Tag;
procedure Insert_Tags is
Stmt : Gnade.Statement;
Tags : Tags_Vectors.Vector;
-- Make necessary arrangements to populate the Stmt and Tags
C : Tags_Vectors.Cursor := Tags.First;
begin
while Tags_Vectors.Has_Element (C) loop
Bind_Tag (Stmt, Tags_Vectors.Element (C)'Access);
Tags_Vectors.Next (C);
end loop;
Gnade.Step (Db, Stmt);
end Insert_Tag;
I'm not sure what kind of thing Tags_Vector.Element (C)
returns. Syntactically, at least, it seems Ada doesn't object to this having an access attribute. But, I don't understand the error (which side does it think is the variable and which side is the constant?) Why is it bad that access to variable designates a constant? (Is it trying to say that I might be changing the value of a constant? -- but I never wanted any of those things to be constants...)