Booch Ada 95 Iteration Version Design Choice Description -------------------------------------------------------- Unlike in Ada 83, the child unit facility of Ada 95 allows iteration over collection types to be defined outside of the definition of those types. All that is needed is for a child iterator to have access to the structure of the associated collection type. The issue is that there are (at least) two ways to rearrange the private parts of the structure components so as to provide access to the type information needed by iterators: The full definition of all of the types that are used to implement the structure components can be exposed or functions that allow read access to the structural information can be declared. Declaring functions would be "more safe" but might be less efficient. Would inlining the newly declared functions increase be required to have performance similar to that of the arrangement that exposes the full type definitions? Does inlining private subprograms increase compilation dependencies for client units _outside_ of the child hierarchy? I have not checked yet whether or not inlining affects the applicability of the elaboration control pragma. (I'm not positive that the two pragmas do not affect each other - if that is the case in general, I'd like to know!) Please note that both designs have been _fully_ implemented for all of the components and that the question is simply which implementation is the most appropriate in keeping with the style and efficiency of the initial design of the components. In other words, what arrangement do you thing that Grady would have chosen? An elided example follows. Full source code for a couple of components is also available. Note that in the "exposed_node" example, one of the components of the node record, "previous" is not needed to support iteration. Also note, however, that the ring component is the _only_ component for which this is the case. The iterators for all other components used all of the parts of the exposed type, as can be seen in the bag source code that is part of the full source code provided. with Booch.Semaphore; generic type Item is private; package Booch.Ring_Concurrent_Unbounded_Managed_Iterator_Original is pragma Elaborate_Body; type Ring is limited private; type Direction is (Forward, Backward); procedure Copy (From_The_Ring : in Ring; To_The_Ring : in out Ring); ... generic with procedure Process (The_Item : in Item; Continue : out Boolean); procedure Iterate (Over_The_Ring : in Ring); ... private type Node; type Structure is access Node; type Ring is record Guard : Semaphore.Kind; The_Top : Structure; The_Mark : Structure; end record; end Booch.Ring_Concurrent_Unbounded_Managed_Iterator_Original; -- Two rearranged designs follow -- with Booch.Semaphore; generic type Item is private; package Booch.Ring_Concurrent_Unbounded_Managed_Exposed_Node is type Ring is limited private; type Direction is (Forward, Backward); procedure Copy (From_The_Ring : in Ring; To_The_Ring : in out Ring); ... private type Node; type Structure is access Node; type Node is -- Exposed record -- Exposed Previous : Structure; -- Exposed - Note: Previous not The_Item : Item; -- Exposed required for Next : Structure; -- Exposed iteration! end record; -- Exposed type Ring is record Guard : Semaphore.Kind; The_Top : Structure; The_Mark : Structure; end record; procedure Seize (The_Ring : in Ring); -- Exposed procedure Release (The_Ring : in Ring); -- Exposed end Booch.Ring_Concurrent_Unbounded_Managed_Exposed_Node; generic with procedure Process (The_Item : in Item; Continue : out Boolean); procedure Booch.Ring_Concurrent_Unbounded_Managed_Exposed_Node. Iterate (Over_The_Ring : in Ring); -- OR --- with Booch.Semaphore; generic type Item is private; package Booch.Ring_Concurrent_Unbounded_Managed_Provided_Functions is type Ring is limited private; type Direction is (Forward, Backward); procedure Copy (From_The_Ring : in Ring; To_The_Ring : in out Ring); ... private type Node; type Structure is access Node; type Ring is record Guard : Semaphore.Kind; The_Top : Structure; The_Mark : Structure; end record; procedure Seize (The_Ring : in Ring); -- Exposed procedure Release (The_Ring : in Ring); -- Exposed function Item_Of (The_Node : in Structure) return Item; -- New function Next_Of (The_Node : in Structure) return Structure; -- New --pragma Inline (...); end Booch.Ring_Concurrent_Unbounded_Managed_Provided_Functions; generic with procedure Process (The_Item : in Item; Continue : out Boolean); procedure Booch.Ring_Concurrent_Unbounded_Managed_Provided_Functions. Iterate (Over_The_Ring : in Ring);