comp.lang.ada
 help / color / mirror / Atom feed
From: mcsun!uknet!stl!crosfield!pdg@uunet.uu.net  (paul goffin)
Subject: Re: 'SIZE attribute of a type
Date: 10 Dec 91 08:23:36 GMT	[thread overview]
Message-ID: <12159@suns3.crosfield.co.uk> (raw)

In article <EACHUS.91Dec6115421@Dr_No.mitre.org> eachus@Dr_No.mitre.org (Robert
 I. Eachus) writes:
>In article <5830@email.sp.unisys.com> parkhill@email.sp.unisys.com (parkhill) 
writes:
>
>>  This is demonstrated when you do a Boolean'SIZE and get 8.  It is
>>  possible for the compiler to use 1 bit but it instead uses 8.
>
>   Not quite.  AI-00536/08-BI-WA requires that Boolean'SIZE = 1.
>Objects of type Boolean may have a size of 8 (or 32, or whatever), but
>Boolean must have 'SIZE = 1 so that (packed) Boolean arrays are bit
>vectors.  Most vendors do fiercely pack bit vectors, but some still
>get Boolean'SIZE wrong.  (This is a very recent AI.) A quick test
>program:
>
[deleted]

A short while ago, I was writing an Ada source code preprocessor/database
system.  This was necessary because of the way we were implementing
a multi-computer system which communicated with shared memory.

I found that some of the assumptions I had made about the Boolean type
used by Telesoft were wrong. (Of course, when I checked the manual, the
correct description was there; I just didn't take it all in when designing
my preprocessor.)

Part of my preprocessor was concerned with sharing memory between systems
programmed in Ada and systems programmed in FORTRAN.  The FORTRAN compiler
allowed a non-zero value to be true.  Ada was far more strict :
16#0000# = False; 16#0001# = True.

That caused a slight upset; but the really annoying thing was:

An object of type Boolean occupied 16 bits.
Arrays of type Boolean consisted of elements each 8 bits in size.

Thus:

	Relay_1 : Boolean;

	Realy_2 : Array 1..2 of Boolean;

	-- These two Objects occupy the same ammount of memory
	-- (Not the same part of it, of course)

(I had assumed - wrongly - that Boolean objects and elements of Boolean
arrays would be the same size.)

Packed Booleans occupied 1 bit, of course.

As I said, the exact representation of Booleans was described in the manual;
my mistake!  Nevertheless, It did seem to me to be an odd representation.
-- 
+-------------+-------------------------------------------------------+
+ Paul Goffin +  Crosfield Electronics Ltd. U.K.  +44 442 230000x3357 +
+             +  My opinions are my OWN. - no one would pay for this  +
+-------------+-------------------------------------------------------+

             reply	other threads:[~1991-12-10  8:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-12-10  8:23 paul goffin [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-12-13 17:24 'SIZE attribute of a type elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!ds
1991-12-13 16:00 Alex Blakemore
1991-12-13 15:23 agate!spool.mu.edu!yale.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!ca
1991-12-12 22:49 Robert I. Eachus
1991-12-12 15:36 elroy.jpl.nasa.gov!sdd.hp.com!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu
1991-12-12 15:18 elroy.jpl.nasa.gov!swrinde!mips!samsung!caen!umeecs!dip.eecs.umich.edu!wa
1991-12-12  3:17 Mark Biggar
1991-12-11 18:29 elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!gv
1991-12-10 12:30 mcsun!uknet!yorkohm!minster!mjl-b
1991-12-09 13:24 Ed Matthews
1991-12-07  0:32 Donald Gardner
1991-12-06 21:14 Ed Matthews
1991-12-06 21:07 Richard Pattis
1991-12-06 20:15 parkhill
1991-12-06 20:04 parkhill
1991-12-06 18:50 Brian Hanafee
1991-11-14 20:15 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!pacbell.com!iggy.GW.Vit
1991-11-14 19:58 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!pacbell.com!iggy.GW.Vit
1991-11-14 16:45 Danford Lehman
1991-11-13 17:01 elroy.jpl.nasa.gov!sdd.hp.com!mips!zaphod.mps.ohio-state.edu!unix.cis.pit
replies disabled

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