comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: A question and a request
Date: Fri, 9 Nov 2001 18:32:03 -0500
Date: 2001-11-09T18:32:03-05:00	[thread overview]
Message-ID: <tuopl7in448a86@corp.supernews.com> (raw)
In-Reply-To: mailman.1005116423.21054.comp.lang.ada@ada.eu.org


"Eric Merritt" <cyberlync@yahoo.com> wrote in message
news:mailman.1005116423.21054.comp.lang.ada@ada.eu.org...
> The addition operator is taking two disparate but
> related types and adding them.

You have to be careful about how you use the terms "type" and "subtype".
The (sub)types you defined simply name subsets of a common type.

> This is fine,
> up-casting is a normal thing. However, when the result
> is returned it is not (should not be?) an instance of
> the subtype.

The addition operator looks like this:

   function "+" (L, R : Integer'Base) return Integer'Base;

Only a "type" has operations.  Subtypes merely name a range of values within
the scalar type.

Your addition operator is returning a value in the set (whose values are
named by the type).  Then there is an assignment, which checks to make sure
the value (on the RHS) lies in the range of the subtype (of the object on
the LHS).

> It seems that the compiler is
> down-casting automatically. This bothers me and it
> seams that is violates Ada's strong typing. What am I
> missing here?

No, it does not, because there is only one type: the type whose first named
subtype is Integer.






  parent reply	other threads:[~2001-11-09 23:32 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-06 16:45 List Container Straw Man Nick Roberts
2001-11-06 17:29 ` Stephen Leake
2001-11-06 18:25   ` Marin David Condic
2001-11-06 23:02     ` Nick Roberts
2001-11-07 19:49       ` Stephen Leake
2001-11-07 20:30         ` Marin David Condic
2001-11-07 23:58           ` Nick Roberts
2001-11-08  4:34             ` Jeffrey Carter
2001-11-08 10:45             ` Ehud Lamm
2001-11-08 19:09               ` Nick Roberts
2001-11-09 16:32                 ` Ted Dennison
2001-11-10  2:20                   ` Nick Roberts
2001-11-10 19:50                     ` Ehud Lamm
2001-11-11  3:48                       ` Nick Roberts
2001-11-08 10:41           ` Ehud Lamm
2001-11-08 19:20             ` Marin David Condic
2001-11-08 20:35               ` Ehud Lamm
2001-11-09 16:39             ` Ted Dennison
2001-11-08  0:06         ` Nick Roberts
2001-11-09 16:16           ` Stephen Leake
2001-11-09 16:24             ` Ehud Lamm
2001-11-09 16:52               ` Brian Rogoff
2001-11-09 18:04             ` Darren New
2001-11-09 20:05               ` Stephen Leake
2001-11-10  3:24             ` Nick Roberts
2001-11-06 23:52   ` Nick Roberts
2001-11-07  4:44     ` A question and a request Eric Merritt
2001-11-07 11:00       ` Preben Randhol
2001-11-07 12:54         ` David C. Hoos, Sr.
2001-11-08  2:35           ` dale
2001-11-07 13:24         ` Eric Merritt
2001-11-07 13:58       ` James Rogers
2001-11-07 16:32       ` Jeffrey Carter
2001-11-09 23:32       ` Matthew Heaney [this message]
     [not found] <3BE93E12.7BB33908@worldnet.att.net>
2001-11-07 17:38 ` Eric Merritt
replies disabled

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