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: Ken Garlington Subject: Re: To Initialise or not Date: 1996/05/13 Message-ID: <31975399.6F2C@lmtas.lmco.com>#1/1 X-Deja-AN: 154644837 references: <318508FE.204B@sanders.lockheed.com> <318E3A26.3565@lmtas.lmco.com> <3190A8D3.3D53@lmtas.lmco.com> <3196FBD9.6AA1@lmtas.lmco.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (Macintosh; I; 68K) Date: 1996-05-13T00:00:00+00:00 List-Id: One correction to an earlier statement I made (which actually has very little to do with explicit initialization to null, but anyway...) 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: 1. With an aliased object. (However, you should be able to use 'Size on the type of that object, at least in some cases). 2. With an object that already takes up all the size available for that architecture (e.g., an integer from System.Min_Int to System.Max_Int). (I don't exactly buy the fixed/floating point restriction, BTW, and I sent in a comment on that). 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. -- LMTAS - "Our Brand Means Quality"