Ada-Rapporteur-Group / User-Community-Input

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

Aspects that denote expressions should not allow aspect_definition to be omitted #65

Open sttaft opened 10 months ago

sttaft commented 10 months ago

Ada RM 13.1.1(15/3) permits aspects of a Boolean type such as "Pack" and "Inline" to be written without an explicit aspect_definition part, such as:

  type String is array (Positive range <>) of Character
     with Pack;

or

   function Get_Field (X : Obj) return Field_Type
     with Inline;

However, it also (implicitly) permits the following:

type Rec is private with Default_Initial_Condition;

or

   function Get_Field (X : Obj) return Field_Type
      with Pre;

both of which seem quite confusing when reading source code.

I would suggest we consider allowing omission of "=> True" only when the aspect denotes a value rather than an object or an expression of Boolean type. Clearly this is not upward compatible, but the fix is trivial, and one could argue improves readability in all such cases.

The suggested modification of 13.1.1(15/3) would be:

The aspect_definition associated with a given aspect_mark may be omitted only when the aspect_mark identifies an aspect {that denotes a value} of a boolean type, in which case it is equivalent to the aspect_definition being specified as True.

Jeff-Cousins commented 10 months ago

➢ I would suggest we consider allowing omission of "=> True" only when the aspect denotes a value rather than an object or an expression of Boolean type

Sounds very sensible to me.

Jeff

Sent from Mail for Windows

ARG-Editor commented 9 months ago

Note that we explicitly disallowed this for Default_Value and Default_Component_Value, even being a value doesn't necessarily make it reasonable to omit the value. But I suppose that makes the most sense. It certainly does not make sense to omit the expression for a contract.