Ada-Rapporteur-Group / User-Community-Input

Ada User Community Input Working Group - Github Mirror Prototype
26 stars 1 forks source link

Duplicated expressions containing pragma Inspection_Point #60

Open nholsti opened 1 year ago

nholsti commented 1 year ago

(I originally made this comment during my review of AI22-0061-1/03 (Assertion policy for duplicated expressions) for WG 9 approval, but we then agreed that it should be a new issue.)

Referring to the discussion of duplicated expressions in AI22-0061-1/03, in addition to pragma Assert, another pragma that can appear in a declare expression is pragma Inspection_Point, by AI22-0045-1/05. While Inspection_Point has no effect on the execution proper, the meaning of a parameterless pragma Inspection_Point depends on the set of objects that are visible at the point of the pragma, and that object set may differ in the different duplications of the expression that contains the pragma. I suggest that there should be a rule to say which of these possibly different visible-object sets is used to define the meaning -- for example, the set at the first occurrence of the expression.

In reply to my WG 9 review comment, Tucker Taft replied as follows: "That seems like a reasonable suggestion. It should probably be a separate AI at this point."

sttaft commented 7 months ago

To clarify for those unfamiliar with AI22-0061, a "duplicated expression" is one that appears twice (lexically) such as in the default for a formal parameter for a subprogram that has a separate specification. Full conformance is required, but the set of visible variables at the two points may differ. It certainly seems reasonable to base the interpretation on the visibility at the first instance of the expression, since that is the one that is generally relevant to most users of the construct (e.g. callers in the case of formal parameter defaults).