comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <mcondic.nospam@acm.org>
Subject: Re: Rep clause problems, was Re: S'Write and How To Count Bytes
Date: 2000/10/03
Date: 2000-10-03T18:29:16+00:00	[thread overview]
Message-ID: <39DA256D.D854277B@acm.org> (raw)
In-Reply-To: F9oC5.278709$i5.3876063@news1.frmt1.sfba.home.com

tmoran@bix.com wrote:

>   So the basic problem is representation clauses, and Streams only come
> into the picture because the rep clauses are giving too many problems.
> And the rep clause problems are specific to tagged types.
> Right?

Well, using the Stream attributes seems to be more of "The Ada Way" to do it, but
as noted, you may not be able to control the representation of individual elements
very well. (Also, there are overhead issues - just in case you're building hard
realtime systems. But thats a complaint that is not universal.) You'd be dependent
on the good graces of your compiler to do the right thing, and changing compilers
or getting new releases might mess up your format. (Obvious example: With a field
of type Integer, a given compiler may give you 16 bits and another might give you
32 bits. The ARM says you should get the normal in-memory representation, but it
is not a promise and you're up against system dependencies.)

So with my technique, you could avoid the whole mess just so long as you could
absolutely control the representation of a tagged record. Various suggestions have
been made to, for example, put a well-rep'd record inside the tagged record, but
this has problems with not allowing class-wide operations to be built. You've got
to build a new set of operations for each new type in the class. Yeah, you can do
it, but then you're defeating the elegance of the solution and forcing a lot of
work on building the descendent types. Also, its tough to come up with good ways
of doing things like checksumming the records and other things that rely on
looking at the whole thing as a unit.

The rep clauses may or may not be specific to tagged records. Some of it seems to
be language rules, but there is some debate about the legalities of it all. Some
of it may be specific to the compiler you pick - after all, it is perfectly legal
for a compiler to say: "I don't give a rat's corpse what you asked for in the rep
clause, this is what you're going to get." Legal - just not useful. I've built a
number of small test examples to try to coerce the representation of tagged
records into what I want and have just never been able to get it to work. Perhaps
I need to find a couple of different compilers and see if the behavior is
universal.

MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Giving money and power to Government is like giving whiskey
    and car keys to teenage boys."

        --   P. J. O'Rourke
======================================================================






  reply	other threads:[~2000-10-03  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-03  0:00 S'Write and How To Count Bytes Mario Amado Alves
2000-10-03  0:00 ` Marin David Condic
2000-10-03  0:00   ` Rep clause problems, was " tmoran
2000-10-03  0:00     ` Marin David Condic [this message]
2000-10-04  0:00       ` Simon Wright
2000-10-06  0:00         ` Marin David Condic
2000-10-07  0:00           ` Simon Wright
replies disabled

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