comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nick.roberts@acm.org>
Subject: Zero_Fill pragma
Date: Tue, 20 Jul 2004 17:22:27 +0100
Date: 2004-07-20T17:22:27+01:00	[thread overview]
Message-ID: <opsbf2fpb0p4pfvb@bram-2> (raw)

Am I too late to make a proposal for a new pragma for
the Ada 2005 Amendment?

It would have the syntax:

    pragma Zero_Fill(simple_name);

It would be applicable to an object or a subtype, and it
would operate on all objects of the given subtype, or on
the given object. The object must be of a composite type.

It would have the effect of causing all the bits in the
object which are unused to have a default initialisation
of 0.

I think the definition of 'in the object' would be any
bit numbered 0 to n-1, where n is the object's size (as
the Size attribute would report).

I think the definition of 'unused' would be any bit
which is not in any of the object's components. If the
place of the component is defined by a record
representation clause, that will define the bits used
by the component, otherwise the bits used by a component
will be chosen by the compiler.

For records, the effect can be achieved by introducing
'dummy' components, but this is a pain and can degrade
readability. For arrays, the effect cannot be achieved
by standard means (other than perhaps adding components
to the array's component subtype, if it is a record
subtype, to bulk the record up to the size of an
integral number of allocation units, and then using
pragma Pack).

Either way, I think the pragma would be useful in real
programs, and that it would be useful for the pragma to
be defined by the language standard. I'm a little
surprised existing compilers don't provide something
like this.

-- 
Nick Roberts



             reply	other threads:[~2004-07-20 16:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-20 16:22 Nick Roberts [this message]
2004-07-20 17:37 ` Zero_Fill pragma Jean-Pierre Rosen
2004-07-20 20:14   ` Nick Roberts
2004-07-20 21:06     ` Jacob Sparre Andersen
2004-07-20 22:15     ` Georg Bauhaus
2004-07-21  7:21     ` Jean-Pierre Rosen
2004-07-21  9:00     ` Martin Dowie
2004-07-20 21:57 ` Frank
  -- strict thread matches above, loose matches on Subject: below --
2004-07-20 17:13 Lionel.DRAGHI
2004-07-21 12:27 ` Marin David Condic
2004-07-22  9:02   ` Dale Stanbrough
2004-07-21  9:24 Lionel.DRAGHI
2004-07-21 12:59 Lionel.DRAGHI
2004-07-21 21:54 ` Marin David Condic
replies disabled

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