comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Building portable data structure (NOT a newbie question?)
Date: 1996/12/27
Date: 1996-12-27T00:00:00+00:00	[thread overview]
Message-ID: <E336qt.BtG@world.std.com> (raw)
In-Reply-To: afniiik9q3c42e.fsf@Elysium.i-have-a-misconfigured-system-so-shoot-me


In article <afniiik9q3c42e.fsf@Elysium.i-have-a-misconfigured-system-so-shoot-me>,
 <afniii@hades.arl.psu.edu> wrote:
>Using streams seems to be the solution.

Yes, probably.

>... Maybe this is a red herring and
>that is why I have not found a good solution yet, but I think not. 
>Unfortunately, I can find no way to override the predefined types 'READ
>'WRITE, "INPUT, and 'OUTPUT attributes. 

Right, you're not allowed to define Integer'Read and whatnot.

>...This would really solve it. Of
>course I could write one of those hated units with new definitions of
>integer, natural, float, etc in them, but I hated that in Ada 83 so I am
>sure I will hate it in Ada 95. Once you make on of those things you have
>to always be dragging it around with a with clause then a use clause for
>the operators and stuff. Heck, if I want to do that I would with and use
>the predefined unit.

One thing you can do is put a whole lot of code in child units of a
given unit.  E.g. you might have:
    
    package Basic_Types is
      ... -- defines your version of Integer and so forth
    end;
    
    with Basic_Types; use Basic_Types;
    package My_Application is end; -- empty package

Then put all the rest of your code under My_Application.  Then,
My_Application.This_Package and My_Application.That_Package can all see
the stuff in Basic_Types without explicitly having to "with" and "use"
it.

Bit_Order specifications are not required on most machines, by the way.
Only on word-addressable machines.  This is because on byte-addressable
machines, they can cause gaps within components, which is a pain for the
compiler.  GNAT might implement them someday, though -- ask ACT.  A
sensible thing to might be to implement the non-default Bit_Order, but
only in the cases where there are no gaps (which is probably your case).

>Then I realized that the output from the streams units may not, and in
>fact are not, be protable because the type element defined in streams is 
>platform or implementation independent. But, if I can get everything 
>uniform in a stream, I can convert the stream to a fixed stream 
>(ie: a byte stream where the element is always defined as mod 8). 

I suspect that Stream_Elements will always be 8 bits, except on unusual
systems.

- Bob




  parent reply	other threads:[~1996-12-27  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-27  0:00 Building portable data structure (NOT a newbie question?) afniii
1996-12-27  0:00 ` Mark Eichin
1996-12-27  0:00 ` Robert A Duff [this message]
1996-12-27  0:00   ` Norman H. Cohen
1996-12-27  0:00 ` Larry Kilgallen
1996-12-27  0:00 ` Robert I. Eachus
replies disabled

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