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,4c459ff0adb576bc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-23 14:55:29 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dewar@gnat.com (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Refactoring and Ada Date: 23 Feb 2002 14:55:29 -0800 Organization: http://groups.google.com/ Message-ID: <5ee5b646.0202231455.317a444a@posting.google.com> References: <3C5AB0B7.9D75D49A@grammatech.com> <3c639940@pull.gecm.com> <4519e058.0202080714.1bf916bb@posting.google.com> <3C65BFF4.F15A07D0@earthlink.net> <3C7324BF.996E182B@adaworks.com> NNTP-Posting-Host: 205.232.38.14 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1014504929 7792 127.0.0.1 (23 Feb 2002 22:55:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 23 Feb 2002 22:55:29 GMT Xref: archiver1.google.com comp.lang.ada:20317 Date: 2002-02-23T22:55:29+00:00 List-Id: Richard Riehle wrote in message news:<3C7324BF.996E182B@adaworks.com>... > Larry Kilgallen wrote: > > > > What happens when you read junk off the interface? > > > > Doesn't 'Valid detect that ? > > It turns out that 'Valid is not as useful as many of us > thought it was. Fo example, the result of an erroneous > result from unchecked conversion What do you mean by "an erroneous result" from unchecked conversion. The word erroneous does not appear in RM section 13.9. Now it is true that UC is implementation defined, and one can imagine an unusable implementation that "defines" the action of some UC's to be the equivalent of erroneous, but if you find such a compiler I suggest you file it in the circular file, since it is working hard to be useless. > which we originally > thought was harmless if we checked it ourselves > with 'Valid before using it is a problem. Consider the > following, > > type X is ... ; > type Y is ... ; > > function Convert is new > Ada.Unchecked_Conversion > (Source => Y, Target => X); > > > X := Convert (Y); -- suppose X is > erroneous or not valid First of all, a value can never be erroneous, this is sloppy terminology. Only a program execution can be erroneous, and certainly one does NOT expect the above to be erroneous on any reasonable compiler. A compiler would have to explicitly document this as erroneous, and it would be treading on thin ice, since the idea of implementation defined is to exclude erroneous behavior. Yes a language lawyer can argue that erroneousity is included in the range of possible impl defined values, but that's no excuse for a compiler to malfunction this way. There are many many ways in which compilers can be made unusable, this is one of them, and there is no reason to put up with it. > if X'Valid then ... -- We used to > think this was OK. It's just fine > -- Some > compilers fail on this because of an > interpretation of the ALRM rules. There is no interpretation involved here, this is a matter of implementation defined behavior. > At present, one must wonder about the usefulness of > 'Valid. That's like finding a compiler that does all multiplications by repeated addition and then wondering about the utility of the * operator in Ada. On a decent compiler, the above works fine, and is a useful (and commonly used) use of 'Valid.