comp.lang.ada
 help / color / mirror / Atom feed
From: "Chris Miller" <chrismil@ozemail.com.au>
Subject: Suggestion for Ada 0X - "Complete" Record Rep Clauses
Date: Sun, 9 Sep 2001 11:08:40 +1000
Date: 2001-09-09T11:08:40+10:00	[thread overview]
Message-ID: <tmCm7.2113$iH4.154993@ozemail.com.au> (raw)

Here is a quick suggestion for Ada 0X. I have no idea if it has been
suggested before.

Record representation clauses (LRM13.5.1) allow the locations for the
components of a record to be specified, but there is no way to ensure that
the location for each and every field is specified. If you do not specify
the location for a component then the compiler can put it anywhere. This is
generally not what is wanted, if a rep clause is used then typically the
location of all fields will need to be specified.

Assume you have

type R is record
  field1 : typea;
  field2 : typeb;
  field3 : typec;
end record;

for R use record
  field1 at 0 range ...;
  field3 at 3 range ...;
end record;

This is probably an error, since the location for field2 has been left out.
In this example it is blatantly obvious, however in real world code (for
example the layout of bus messages) there can be many fields and it is easy
to leave one out. This can lead to hard to find errors.

The addition could be to allow an optional reserved work "all" in the record
rep clause, in this case it would be a compile time error if the component
clauses for all fields were not specified.

So you would get

for R use all record
  field1 at 0 range ...;
  field2 at 3 range ...;
  field3 at 7 range ...;
end record;

This would be trivial to implement, and 100% upward compatible with current
code. May also wish to have a pragma that specifies that all record rep
clauses in its scope are complete. This could be either a new pragma or part
of pragma Restrictions, in the Safety & Security Annex.

Comments ??

Chris Miller
chrismil at ozemail dot com dot au
9 Sept 2001.






             reply	other threads:[~2001-09-09  1:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-09  1:08 Chris Miller [this message]
2001-09-09 12:42 ` Suggestion for Ada 0X - "Complete" Record Rep Clauses Marc A. Criley
2001-09-09 15:53 ` Robert Dewar
2001-09-10  5:44 ` Florian Weimer
2001-09-10 12:13   ` Marc A. Criley
2001-09-18 15:06   ` 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