From: elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!ds inc!gvlf3.gvl.unisys.com!email!parkhill@ames.arc.nasa.gov (parkhill)
Subject: Re: 'SIZE attribute of a type
Date: 13 Dec 91 17:24:40 GMT [thread overview]
Message-ID: <5907@email.sp.unisys.com> (raw)
warack@dip.eecs.umich.edu (Christopher Warack) writes:
> In article <5898@email.sp.unisys.com> parkhill@email.sp.unisys.com (parkhill)
writes:
> >>>Image a compiler was smart enough to understand baised number ranges.
> >>
> >>> type b is range 9 .. 10;
> >>> or
> >>> type b is range 2**31 - 2 .. 2**31 - 1;
> >>
> >>
> >>>If the compiler can generate code that only uses 1 bit then b'Size
> >>>should return 1.
> >>
> >>Oh, that compilers were so cleverly written!
> >>
> >
> >> Deleted text.
> >
> >My point on the compiler having the capability to use one bit is that I
> >find the utility of type_name'size is now questionable. Lets say the
> >compiler is capable of using 1 bit but won't do it in most situations.
> >How can any programmer use type_name'size to any practical purpose? It
> >seems less useful than Entry_Name'Count. However, I am sure that the
> >justification for the change to type_name'size is rock solid.
>
> Seems to me that the only reason you'd want the minimum number of bits
> used to represent a type is if you wanted to implement that type with the
> minimum number of bits allowed, eg, in a maximally packed record using
> a "somewhat" portable rep clause. (Not the most beautiful piece of code I
> can imagine).
>
> If you wanted to know the number of bits in a certain type of object (e.g,
> a variable of a type) use object'size -- that's what it's for.
>
> -- Chris
>
> --
> Christopher A. Warack warack@eecs.umich.edu
> Graduate Dept, EECS (313) 665-4789
> University of Michigan
You are quite correct, one of the only reasons you would want to use the
minimum number of bits that minimum bits are required. I am often
required to write device drivers in Ada. The device being communicated
with sets the protocol. Some of the military devices I communicate with
used biased representation for input and output values. If the compiler
could generate code for this I wouldn't have to do it. I think
portability goes or when you are doing memory mapped I/O to external devices.
Yes, I know Object_Name'Size tells you the number of bits used by an
object. What is Type_Name'Size for??
Robert Parkhill
next reply other threads:[~1991-12-13 17:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-12-13 17:24 elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!ds [this message]
-- strict thread matches above, loose matches on Subject: below --
1991-12-13 16:00 'SIZE attribute of a type 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-10 8:23 paul goffin
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