From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-91-241.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.0 required=3.0 tests=AC_FROM_MANY_DOTS, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.6 X-Received: by 2002:ad4:5983:0:b0:655:baed:c94b with SMTP id ek3-20020ad45983000000b00655baedc94bmr41486qvb.0.1695500530508; Sat, 23 Sep 2023 13:22:10 -0700 (PDT) X-Received: by 2002:a05:6870:1aad:b0:1d6:4b44:a3d0 with SMTP id ef45-20020a0568701aad00b001d64b44a3d0mr1277667oab.6.1695500530351; Sat, 23 Sep 2023 13:22:10 -0700 (PDT) Path: eternal-september.org!news.eternal-september.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 23 Sep 2023 13:22:09 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=213.108.152.51; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S NNTP-Posting-Host: 213.108.152.51 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <22930fd1-c7ff-46cf-8c75-892212afa85en@googlegroups.com> Subject: Valid attribute and input operations From: Maciej Sobczak Injection-Date: Sat, 23 Sep 2023 20:22:10 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2858 Xref: news.eternal-september.org comp.lang.ada:65706 List-Id: Hi there, I am in the middle of a heated debate with Richard Riehle on LinkedIn, wher= e we cannot get to terms with regard to the exact semantics of X'Valid in t= he context of input operations performed by standard Get procedure. In short, consider the following example: with Ada.Text_IO; with Ada.Integer_Text_IO; procedure Is_Valid_Test is X : Integer range 0..200; begin Ada.Text_IO.Put("Get an Integer: "); Ada.Integer_Text_IO.Get(X); if X'Valid then Ada.Text_IO.Put_Line("The Input is Valid "); else Ada.Text_IO.Put_Line("The Input is not Valid "); end if; end Is_Valid_Test; When the input is 500, what should be the behavior of this program? There are two interpretations: 1. Get is an input operation and can create invalid representations (as sta= ted in 13.9.2, p.7). Then, the X'Valid test that follows Get(X) can be used= to safely recognize whether the value is in the range or not. The program = should print the second string (from the else branch), but should not raise= any exceptions for this input (500). 2. Get is not an input operation in the meaning referred to in 13.9.2/7, or= is an input, but only for type Integer (and it cannot create invalid integ= er representations on typical computers anyway). The X variable is an actua= l parameter that has a subtype that is different from the formal parameter = and is subject to conversions when the Get subprogram exits normally (6.4.1= /17,17a). This conversion should raise Constraint_Error for this input (500= ). I have checked the above program on several on-line compilers, all of them = behave according to interpretation 2 above. Richard claims to get behavior 1 on his compiler. What is your take on this? Any language lawyers? Regards, Maciej Sobczak