TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mike Smith <[log in to unmask]>
Reply To:
Date:
Mon, 15 Nov 1999 14:19:49 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Tucker,

Thanks for the clarification -- I really appreciate your help.  I knew
there was some reason why I'd never run into any problems with subtypes
before.  So, basically the subtype example you and I gave is really a
constrained subtype assuming that the "parent" type is constrained.

I tell you, sometimes perusing through these language books can get you
wrapped around the axle.

Thanks again,
Mike

-----Original Message-----
From:   Tucker Taft [SMTP:[log in to unmask]]
Sent:   Monday, November 15, 1999 2:07 PM
To:     [log in to unmask]
Subject:        Re: Using Unconstrained Subtypes for Type Renaming

Mike Smith wrote:
>
> Hi Tucker,
>
> Thanks for getting back to me on this.  Yes, I understand the use of the
> overflow flag with respect to the constraint error. Barnes' example
showed
> how two variables of the same unconstrained subtype may be mapped to
> differently sized registers (32 bit) and memory locations (16 bit) which
> produces overflows at different values.  Anyway his example is only
> tangentially related to my own use of subtypes.  However, I thought it
> raised an interesting issue with type renaming.  For example, I've got a
> type called te_Blah_Blah_Blah_Really_Long_Name and I'd like to refer to
it
> as Short_Name, so I use the following renaming definition:  subtype
> Short_Name is te_Blah_Blah_Blah_Really_Long_Name;
>
> What really makes this interesting is that I received
> te_Blah_Blah_Blah_Really_Long_Name late in the coding game, so I guessed
> it's name to be Short_Name while writing my code.  When I finally receive
> the actual type name and definition I only had to replace the temporary
> Short_Name definition with the above definition.  Regardless, I would
like
> variables of type Short_Name to be range checked against the range of
> te_Blah_Blah_Blah_Really_Long_Name and that is what I am concerned about.

You would have to make an extra effort to "turn off" the constraint
checking.  In general, when you write:

    subtype S is Blah;

S and Blah are identical in every way, including constraints.

If you want to remove the range constraint, you would have to write:

    subtype S is Blah'Base;


> Thanks,
> Mike
--
-Tucker Taft   [log in to unmask]   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA

ATOM RSS1 RSS2