comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: type and subtype
Date: Mon, 25 Jul 2005 08:41:48 -0700
Date: 2005-07-25T08:41:48-07:00	[thread overview]
Message-ID: <0L7Fe.3$Jf6.1@dfw-service2.ext.ray.com> (raw)
In-Reply-To: <b4k0ygaqf0u4$.102vj4zdpubdy.dlg@40tude.net>

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

Dmitry A. Kazakov wrote:
> 
> I think that Ludovic's view is more consistent: checks are just a part of
> the conversion which otherwise is an identity function, because *presently*
> the representation is required to be same. But representation is an
> implementation detail and thus cannot count. Moreover it is very desirable
> to allow subtypes having different representations.

Try this with your favorite compiler:

Ada.Text_IO.Put_Line
    (Item => "Integer'Size =" & Integer'Image (Integer'Size) ):
Ada.Text_IO.Put_Line
    (Item => "Natural'Size =" & Integer'Image (Natural'Size) ):

You're likely to get something like

Integer'Size = 32
Natural'Size = 31

because representations of subtypes are not required to be the same.

We can also consider

type Rec (Length : Positive) is record
    V : String (1 .. Length);
end record;

subtype Small is Rec (Length =>     1);
subtype Big   is Rec (length => 1_000);

where Small and Big have significantly different representations. Then 
there are subtypes of variant record types with discriminants that 
select different variants.

[-- Attachment #2: spam.vcf --]
[-- Type: text/x-vcard, Size: 177 bytes --]

begin:vcard
fn:Jeffrey Carter
n:;Jeffrey Carter
email;internet:jeffrey_r_carter-nr [commercial-at] raytheon [period | full stop] com
x-mozilla-html:FALSE
version:2.1
end:vcard


  reply	other threads:[~2005-07-25 15:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-24 14:24 type and subtype Douglas Chong
2005-07-24 14:39 ` Dmitry A. Kazakov
2005-07-25 17:07   ` Martin Krischik
2005-07-24 16:20 ` Ludovic Brenta
2005-07-24 16:40   ` Jeffrey Carter
2005-07-25  8:23     ` Dmitry A. Kazakov
2005-07-25 15:41       ` Jeffrey Carter [this message]
2005-07-25 21:59         ` Ludovic Brenta
2005-07-26  8:21         ` Dmitry A. Kazakov
2005-07-25 17:02 ` Martin Krischik
replies disabled

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