Version 1.2 of si99s/si99-0020-1.txt
!standard 14.1 06-09-25 SI99-0020-1/01
!class binding interpretation
!status No Action (12-0-0) 06-11-17
!status work item 06-09-25
!status received 06-09-25
!priority Medium
!difficulty Easy
!qualifier
!subject Use "is null" defaults in Traverse_Element
!summary
Make use of the new Ada2005 "is null" for default subprograms for the
pre- and post-operation of Asis.Iterator.Traverse_Element.
!question
In most cases, only one of the pre-operation and the post-operation is
used in instantiations of Traverse_Element. This forces the user to
explicitely declare null procedures for the othe operation. Note that
since one of the parameters of these procedures is of the generic type
State_Information, it is not possible to have just one default that
would serve for all instantiations.
!recommendation
(See summary.)
!wording
Change the declaration in Asis.Iterator (14.1):
generic
type State_Information is limited private;
with procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information) is <>;
with procedure Post_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information) is <>;
procedure Traverse_Element
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information);
To:
generic
type State_Information is limited private;
with procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information) is null;
with procedure Post_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information) is null;
procedure Traverse_Element
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information);
!discussion
This change is non upward-compatible, since an instantiation that was
using the default will now use a null procedure. In practice, this
should not be a big problem because:
1) It is good practice to explicitely give the procedures anyway.
2) Bugs resulting from this incompatibility will be found very easily,
since the corresponding operation will cease to work completely.
3) The fix is straightforward.
On the other hand, specifying the null procedure for almost every
instantiation is a burden, and it adds many useless procedures to the
code that hamper readability. Therefore, it seems that the benefits
outweigh the cost of the incompatibility.
!appendix
****************************************************************
Questions? Ask the ACAA Technical Agent