comp.lang.ada
 help / color / mirror / Atom feed
From: cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner@uunet.uu.net  (Don Gardne
Subject: Re: Data Overlays
Date: 19 Aug 93 13:16:24 GMT	[thread overview]
Message-ID: <1993Aug19.131624.2392@titan.tsd.arlut.utexas.edu> (raw)

jcrigler@theopolis.orl.mmc.com (Jim Crigler) writes:

>Bill Lee (bill@leeweyr.sccsi.com) wrote:
>: In article <1993Aug13.124835.18422@iplmail.orl.mmc.com>
>: rgilbert@orl.mmc.com writes:
>: >
>: >Many times I have wanted to create two different types to look at the
>: >same object.
>:
>: O.k., Here's my problem:

>: I have a system which receives "messages" from a number of other
>: systems. The messages come via POSIX queues. On any one queue, I
>: can receive a number of different messages, mostly with record
>: structures defined by the C code where the message originated.

>: I do not know a priori what the next message will be. I have to
>: "receive" the message into a Byte_Array. Once I have the message,
>: I can access a standard header and extract a message identifier,
>: which then tells me what kind of message I've just received.

>What about a variant record?  Language Lawyer question (my LRM is at
>home):  are rep. specs allowed on variant records?  If so (and if you
>have a single tag at any level that determines what the message is at
>that level), use an address clause to store the data on the Byte_Array,
>then use the variant to figure out what you've got.

I have had some difficulty using representation specifications
in code that is supposed to be portable.  In particular, in an
attempt to port a large amount of communication protocol code
from a 68030 platform to a SPARC, we found that a representation
clause caused a "bus error" during elaboration because 16-bit
integers were mapped to odd addresses in records defining
messages.  Unfortunately, the types that have this problem are
widely used throughout the code and are controlled by someone
else.  When they modify the code we have to port the
modification.

IMHO, the problem boils down to the fact that my preference is
to structure my code into 3 steps which are as completely
separated as possible.  These steps are:

    1.  Convert the input from some external representation to a
        native/natural representation for the problem.
    2.  Process the data.
    3.  Convert the output from its native/natural representation
        to some external representation.

Representation clauses violate this separation because they
cause assignment statements throughout the processing step to
also become conversions.

The realization that these steps are being followed also helps
one structure the code and types such that when data are
processed in several phases, the representation used in each
phase is the natural representation for that phase and can be
changed without affecting the other phases.  Only the conversion
code needs to be modified.

             reply	other threads:[~1993-08-19 13:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-19 13:16 cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-01 14:36 Data Overlays David Emery
1993-09-01  4:23 Jim Lonjers
1993-08-31 20:36 dog.ee.lbl.gov!agate!howland.reston.ans.net!math.ohio-state.edu!magnus.ac
1993-08-31  3:51 Jim Lonjers
1993-08-23 14:17 Bob Crispen
1993-08-23 14:11 Alex Blakemore
1993-08-19  2:18 portal!cup.portal.com!R_Tim_Coslet
1993-08-18 16:40 cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmail
1993-08-18 16:27 Charles H. Sampson
1993-08-18 16:04 Charles H. Sampson
1993-08-18 12:55 cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmail
1993-08-18 12:50 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!europa.eng.gtefsd.com!fs7.ece.cmu.edu!news.sei.cmu.edu!firth
1993-08-18  2:11 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!do
1993-08-18  1:53 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
1993-08-18  0:39 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!cs.utexa
1993-08-17 15:16 Charles H. Sampson
1993-08-13 17:57 cgl!sgiblab!darwin.sura.net!mlb.semi.harris.com!x102a!scook
1993-08-13 12:48 Bob Gilbert
replies disabled

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