comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Converting access values
Date: Thu, 06 Jan 2005 00:18:15 GMT
Date: 2005-01-06T00:18:15+00:00	[thread overview]
Message-ID: <bt%Cd.1342$Pm6.1117@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <m3acrnwlsi.fsf@0x535ba1f6.boanxx18.adsl-dhcp.tele.dk>

Mark Lorenzen wrote:

> Hello,
> 
> Imagine that we have a program that reads large amount of data from
> (for example) a network connection into buffers. The data is just to
> be seen as a sequence of octets.
> 
> We now want to copy parts ("slices") of the data to other tasks that
> may do something interesting with these slices. The rate of data is
> too high to simply copy the wanted slices, so instead we make "cheap
> copies".
> 
> The idea is that these cheap copies simply point to slices within the
> large buffer and this way all copies refer to a common buffer and no
> real copying is going on.

The answer, as is often the case with Ada, is that you don't need to use 
access types to do what you want. Assuming you have a big Storage_Array 
and want to pass a slice of it somewhere, just pass the slice:

Buf : Stream_Element_Array (Really_Big);
...
procedure Do_Something (Data : in [out] Stream_Element_Array);
...
Do_Something (Data => Buf (Low .. High) );

I don't know of any compiler that will pass Data by copy; if yours does, 
you should seriously consider changing compilers. What will be passed is 
a slice descriptor, which may be bigger than an access value but will 
still be very small. Actual access to the buffer will be by reference.

-- 
Jeff Carter
"It's all right, Taggart. Just a man and a horse being hung out there."
Blazing Saddles
34



  parent reply	other threads:[~2005-01-06  0:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-05 22:31 Converting access values Mark Lorenzen
2005-01-05 23:32 ` Stephen Leake
2005-01-05 23:51   ` Mark Lorenzen
2005-01-06  0:18 ` Jeffrey Carter [this message]
2005-01-06  0:28   ` Mark Lorenzen
2005-01-07 16:55     ` Nick Roberts
2005-01-07 19:49       ` Mark Lorenzen
2005-01-07 20:23         ` Nick Roberts
2005-01-07 21:23           ` Robert A Duff
2005-01-11 17:02             ` Upkeep
2005-01-11 21:37               ` Robert A Duff
2005-01-12  4:56                 ` Alexander E. Kopilovich
2005-01-12 10:48                 ` Dmitry A. Kazakov
2005-01-07 21:17         ` Randy Brukardt
2005-01-07 22:15           ` Robert A Duff
2005-01-06 10:52 ` Dmitry A. Kazakov
2005-01-06 11:02 ` Duncan Sands
2005-01-06 12:17   ` Martin Dowie
2005-01-06 19:30   ` Mark Lorenzen
2005-01-06 20:40     ` Randy Brukardt
replies disabled

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