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,c1131ea1fcd630a X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: To Initialise or not Date: 1996/05/13 Message-ID: #1/1 X-Deja-AN: 154648616 references: <318508FE.204B@sanders.lockheed.com> <3196FBD9.6AA1@lmtas.lmco.com> <31975399.6F2C@lmtas.lmco.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-05-13T00:00:00+00:00 List-Id: In article <31975399.6F2C@lmtas.lmco.com>, Ken Garlington wrote: >I said that you should be able to use 'Size to ensure that an invalid >representation of a scalar exists. AI95-00051 correctly points out that >there will be at least two cases where this shouldn't happen: But note that AI-51 has not yet been approved by the ARG. This AI was considered at the November meeting, and I rewrote it to reflect my understanding of the concensus. It will be considered again at the June meeting, but the current (draft) version has no official status -- it's just my personal opinion. >So, what do you do then? Well, it seems to me that you could have, in >the body of the abstraction, a check to see if an invalid value is >possible. At least, you can check integers and enumeration values >against System.Max_Int; I'm guessing there's a more general case that >would handle modular types, and maybe the other cases,too. Anyway, >assuming you could devise such a test, you could have that test done >during the elaboration of the type abstraction and cause Program_Error >to be raised. Then, you could have a second generic that would be used >in those cases, which would have the type wrapped in a record that also >contained a boolean called "Unset". The code in the ADT could >initialize this to True, and then set it to False any time a Set >operation was called. That's a little slow, but you would only need it >for those types that can't have their own built-in out-of-range value, >which should be a fairly small subset of the types in an average >program. Well, type Character uses all the bits up on most implementations, and (in a packed array) Boolean uses up all the bits (namely 1 bit). Type Integer uses up all the bits on most implementations. These aren't things that you normally encapsulate in an "abstraction". - Bob