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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ea7ac816f5c3d0a7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-25 08:22:15 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: adam@irvine.com (Adam Beneschan) Newsgroups: comp.lang.ada Subject: Re: Wide_Text_IO: bad data in text file Date: 25 Oct 2002 08:22:15 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1035559335 8196 127.0.0.1 (25 Oct 2002 15:22:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Oct 2002 15:22:15 GMT Xref: archiver1.google.com comp.lang.ada:30137 Date: 2002-10-25T15:22:15+00:00 List-Id: "Grein, Christoph" wrote in message news:... > > The RM doesn't specifically address this issue, as far as I can tell. > > Data_Error seems to be intended for cases where characters can be read > > from the file but they're not in the proper syntax for an integer > > (when using an instance of Integer_IO), or a float, or whatever. The > > closest thing I could find was A.13(10), which says "Use_Error is > > propagated if an operation is attempted that is not possible for > > reasons that depend on characteristics of the external file". When I > > tried a test using GNAT, it raised Constraint_Error, which seems > > counterintuitive. > > Exactly when did Gnat raise Constraint_Error? At the Get? Or later when you > use the value read? The exception was raised by Get. > My interpretation of the RM is that Data_Error should be raised, however it > need not be raised if this would be too much of a burden (cannot be easily > done). If Data_Error is not raised, you have invalid data. > > The 'Valid attribute can be used to insure that the data read really is valid > (i.e. has a legal interpretation). This attribute is there for just this > purpose. Sorry, this doesn't make sense to me. Unless I'm missing something, I don't think it's possible for Wide_Character'Value ever to return False in GNAT or in most other implementations. This is because a Wide_Character would be represented in memory by a 16-bit object, and all 2**16 possible 16-bit values are valid representations for a Wide_Character. The issue here isn't whether an Ada object (which would be in memory or registers) is valid but whether a bit sequence in the *file* is valid. (In UTF-8, e.g., it takes 8 to 24 bits to represent a Wide_Character.) I don't see how 'Valid can be used to test that. -- Adam