$33.4 HIDING THE REPRESENTATION:THE PRIVATE STORY 1087 private type STACK_VALUES is array (POSITIVE range <>of G; type STACK (capacity:POSITIVE)is record implementation:STACK VALUES (1..capacity), count:NATURAL:=0; end record end STACKS; Note how type STACK must now be declared twice:first in the non-private part of the interface,where it is only specified as private;then again in the private part,where the full description is given.Without the first declaration,a line of the form s:REAL STACK would not be legal in a client,since clients only have access to entities declared in the non-private part.This first declaration only specifies the type as private,barring clients from accessing any property of stack objects other than universal operations such as assignment,equality test and use as actual argument.This is consistent with the discussion of information hiding. Type STACK VALUES is purely internal,and irrelevant to clients:so it need only be declared in the package body. [1]was onpage 1085 Make sure to understand that the information in the private part should really be in the package body,and only appears in the package specification for reasons of language implementation.With the new form of STACKS client code such as [1],which directly accessed the representation in a client,becomes invalid. See“common mis- Authors of clients modules can see the internal structure of STACK instances,but nderstanding”dis they cannot take advantage of it in their modules.This can be tantalizing (although one cussed on page 52. may imagine that a good Ada environment could hide this part from a client author requesting interface information about the class,in the manner ofthe short tool ofearlier chapters).While surprising to newcomers,the policy does not contradict the rule of information hiding:as was pointed out during the discussion of that rule,the goal is not physically to prevent client authors from reading about the hidden details,but to prevent them from using these details. Someone who would like to make things sound very complicated could summarize by the following two sentences (to be spoken very quickly to impress friend and foe):The private section of the public part ofa package lists the implementation ofthose conceptually private types which must be declared in the public part although their implementation is not publicly available.In the non-private part,these types are declared private.§33.4 HIDING THE REPRESENTATION: THE PRIVATE STORY 1087 private type STACK_VALUES is array (POSITIVE range <>) of G; type STACK (capacity: POSITIVE) is record implementation: STACK_VALUES (1..capacity); count: NATURAL := 0; end record end STACKS; Note how type STACK must now be declared twice: first in the non-private part of the interface, where it is only specified as private; then again in the private part, where the full description is given. Without the first declaration, a line of the form s: REAL_ STACK would not be legal in a client, since clients only have access to entities declared in the non-private part. This first declaration only specifies the type as private, barring clients from accessing any property of stack objects other than universal operations such as assignment, equality test and use as actual argument. This is consistent with the discussion of information hiding. Type STACK_VALUES is purely internal, and irrelevant to clients: so it need only be declared in the package body. Make sure to understand that the information in the private part should really be in the package body, and only appears in the package specification for reasons of language implementation. With the new form of STACKS client code such as [1], which directly accessed the representation in a client, becomes invalid. Authors of clients modules can see the internal structure of STACK instances, but they cannot take advantage of it in their modules. This can be tantalizing (although one may imagine that a good Ada environment could hide this part from a client author requesting interface information about the class, in the manner of the short tool of earlier chapters). While surprising to newcomers, the policy does not contradict the rule of information hiding: as was pointed out during the discussion of that rule, the goal is not physically to prevent client authors from reading about the hidden details, but to prevent them from using these details. Someone who would like to make things sound very complicated could summarize by the following two sentences (to be spoken very quickly to impress friend and foe): The private section of the public part of a package lists the implementation of those conceptually private types which must be declared in the public part although their implementation is not publicly available. In the non-private part, these types are declared private. [1] was on page 1085. See “common misunderstanding” discussed on page 52