tags:

views:

103

answers:

2

Has anyone had trouble with the Clear procedure found in the Ada.Containers package? It seems to set the Container's length to zero, but once another element is added using the Append procedure, the contents of the Container reappear (i.e. they never get removed). I've tried both Ada.Containers.Doubly_Linked_Lists and Ada.Containers.Vectors. Both Containers have the same behavior. Any thoughts?

A: 

It sounds to me like you found a bug in your compiler's implementation of that package. I'd report it.

T.E.D.
A: 

I figured it out. Silly Ada. You have to be careful how you reference data. Ada likes to return copies of data instead of references to it.

mike boldischar
Actually, your Ada compiler can return data however it likes. If you *require* a reference passing mechanisim, you must either pass the parameter using the "access" method, or you should use pass a reference to the data type instead. I think the only exception is tagged types, which have to be passed by reference.
T.E.D.