comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Garlington <garlingtonke@lmtas.lmco.com>
Subject: Re: To Initialise or not
Date: 1996/05/13
Date: 1996-05-13T00:00:00+00:00	[thread overview]
Message-ID: <31975399.6F2C@lmtas.lmco.com> (raw)
In-Reply-To: 3196FBD9.6AA1@lmtas.lmco.com


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"




  reply	other threads:[~1996-05-13  0:00 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-29  0:00 To Initialise or not Steve O'Neill
1996-04-29  0:00 ` Ken Garlington
1996-04-29  0:00   ` Robert Dewar
1996-04-30  0:00     ` Ken Garlington
1996-04-30  0:00   ` Robert A Duff
1996-04-30  0:00     ` Robert A Duff
1996-04-30  0:00     ` Ken Garlington
1996-04-30  0:00       ` Robert A Duff
1996-05-01  0:00         ` Keith Thompson
1996-05-01  0:00           ` Robert A Duff
1996-05-02  0:00             ` Keith Thompson
1996-05-03  0:00               ` Robert A Duff
1996-05-01  0:00           ` Theodore E. Dennison
1996-05-01  0:00             ` Robert A Duff
1996-05-02  0:00               ` Theodore E. Dennison
1996-05-02  0:00                 ` Robert A Duff
1996-05-02  0:00                 ` Chris Warack <sys mgr>
1996-05-02  0:00                   ` Robert A Duff
1996-05-06  0:00                   ` Ken Garlington
1996-05-02  0:00               ` Michael F Brenner
1996-05-02  0:00                 ` Robert A Duff
1996-05-04  0:00                   ` Kevin D. Heatwole
1996-05-06  0:00               ` Ken Garlington
1996-05-07  0:00                 ` Robert A Duff
1996-05-08  0:00                   ` Ken Garlington
1996-05-08  0:00                     ` Robert A Duff
1996-05-09  0:00                       ` Ken Garlington
1996-05-09  0:00                         ` Robert A Duff
1996-05-01  0:00             ` Dale Stanbrough
1996-05-02  0:00             ` Robert Dewar
1996-05-02  0:00               ` Theodore E. Dennison
1996-05-02  0:00               ` Robert A Duff
1996-05-06  0:00           ` Ken Garlington
1996-05-06  0:00         ` Ken Garlington
1996-05-07  0:00           ` Robert A Duff
1996-05-08  0:00             ` Ken Garlington
1996-05-09  0:00               ` Robert A Duff
1996-05-10  0:00                 ` Robert A Duff
1996-05-10  0:00                   ` Ken Garlington
1996-05-10  0:00                     ` Robert A Duff
1996-05-10  0:00                       ` Ken Garlington
1996-05-11  0:00                         ` David Kristola
1996-05-11  0:00                           ` Robert A Duff
1996-05-11  0:00                         ` Robert A Duff
1996-05-13  0:00                 ` Ken Garlington
1996-05-13  0:00                   ` Ken Garlington [this message]
1996-05-13  0:00                     ` Robert A Duff
1996-05-13  0:00                       ` Ken Garlington
1996-05-13  0:00                   ` Robert A Duff
1996-05-13  0:00                     ` Ken Garlington
1996-05-01  0:00     ` Patrick Richard Wibbeler
1996-05-06  0:00       ` Ken Garlington
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox