comp.lang.ada
 help / color / mirror / Atom feed
From: lutz@iks-jena.de (Lutz Donnerhacke)
Subject: Re: 'Size (novice question)
Date: 2000/02/22
Date: 2000-02-22T00:00:00+00:00	[thread overview]
Message-ID: <slrn8b50op.ig.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: 87aekxlz33.fsf@deneb.cygnus.argh.org

* Florian Weimer wrote:
>   Put ("Boolean'Size (type):     "); Put (Boolean'Size); New_Line;
>   Put ("Boolean'Size (variable): "); Put (X'Size); New_Line;
>
>Almost no compiler will print 1 twice because on most architectures,
>access to individual bits is expensive in both time and space when
>compared to word or even octet access.

But the following code can not use compressed variables:

with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Size_Difference is
   X1, X2 : Boolean;
   A1, A2 : array (1..8) of Boolean;
   pragma Pack (X2,A2);  -- I know, that a named array subtype is packable.
begin
   Put ("Boolean'Size (type): "); Put (Boolean'Size); New_Line;
   Put ("Boolean'Size (X1):   "); Put (X1'Size); New_Line;
   Put ("Boolean'Size (X2):   "); Put (X2'Size); New_Line;
   Put ("Boolean'Size (A1):   "); Put (A1'Size); New_Line;
   Put ("Boolean'Size (A2):   "); Put (A2'Size); New_Line;
end;





  parent reply	other threads:[~2000-02-22  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <38ACA68D.CEA7E03F@interact.net.au>
2000-02-18  0:00 ` 'Size (novice question) Jeff Carter
     [not found] ` <wccsnyqof2a.fsf@world.std.com>
     [not found]   ` <slrn8aqgfn.15u.lutz@taranis.iks-jena.de>
2000-02-22  0:00     ` Vladimir Olensky
2000-02-22  0:00       ` Robert Dewar
     [not found]     ` <87aekxlz33.fsf@deneb.cygnus.argh.org>
2000-02-22  0:00       ` Lutz Donnerhacke [this message]
2000-02-22  0:00         ` Florian Weimer
2000-02-23  0:00           ` Lutz Donnerhacke
replies disabled

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