From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8fd1e0ee9551e3e6,start X-Google-Attributes: gid103376,public From: Pierre Van Aswegen Subject: New language feature to check record coverage? Date: 1997/02/25 Message-ID: <33139C04.57DB@iossvr.gm.hac.com>#1/1 X-Deja-AN: 221457358 Content-Type: text/plain; charset=us-ascii Organization: MacDonald Dettwiler Mime-Version: 1.0 Newsgroups: comp.lang.ada X-Mailer: Mozilla 3.01 (X11; I; SunOS 5.5 sun4m) Date: 1997-02-25T00:00:00+00:00 List-Id: I would like those who collect ideas for the evolution of the language to tell me what they think of the following idea. It is unprecedented in any language I know, but suggested slightly by combining the idea that the compiler checks that you have an entry for each value in a case statement and the use of record aggregate assigment to ensure you have a value for each member of the aggregate. The need I perceive stems from writing a validation function to certify that the values in a record are consistent. If I change the definition of the record (or miss a member in the original function), the compiler is not going to remind me to update the validation function. (As it would remind me to fix case statements if I changed an enumeration or to fix an aggregate assignment of said changed record.) I have encountered other situations where I've wished to have some guarantee that I was addressing every part of a record. What one needs is a kind of iterator for which the user must supply an operation for each member of a record. (Some members can share an operation.) A reasonably understandable syntax can be derived from either case or aggregation. type Some_Record is record A_Member : MemberA; B_Member : MemberB; ... end record; function Is_Consistent return Boolean is Answer : Boolean := True; begin case Members'Some_Record --* when A_Member => ...; --* when B_Member => ...; --* ... end case; return Answer; end Is_Consistent; function Is_Consistent return Boolean is Answer : Boolean := True; begin Members'Some_Record --* (A_Member => ..., --* B_Member => ..., --* ...) return Answer; end Is_Consistent; *"fantasy Ada"