From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c4003439e5ce36e1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!newsfeed.stueberl.de!newsfeed.vmunix.org!newsfeed.hanau.net!news-fra1.dfn.de!news.tele.dk!not-for-mail Sender: malo@0x53586c58.boanxx18.adsl-dhcp.tele.dk Newsgroups: comp.lang.ada Subject: Re: Converting access values References: From: Mark Lorenzen Date: 07 Jan 2005 20:49:32 +0100 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: TDC Totalloesninger NNTP-Posting-Host: 83.88.108.88 X-Trace: 1105127373 dtext02.news.tele.dk 169 83.88.108.88:2109 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:7545 Date: 2005-01-07T20:49:32+01:00 List-Id: Nick Roberts writes: > Mark Lorenzen wrote: > > > ... > > My problem is not passing a slice as an actual parameter to a subprogram. > > I have a task which receives Buf, slices it up and then passes the slices > > to other tasks using queues implemented as protected types. When passing > > the slice to a queue, it will probably not be done by copy, but the queue > > puts the slice into a data structure (list, array etc.) and there we > > definately have a real assignment and copy. > > Mark, you are a silly sausage! All you do is pass the /bounds/ to the tasks. > When a task finally comes to actually process a slice, it uses the bounds > passed to it to obtain the actual slice of the buffer. Since there is only > one buffer, it can be a global, and parts of it do not need to be passed as > a parameter anywhere. Would this not work for you? As I said in another posting, I am going for a design like this: type Buffer_Slice is record Data : Buffer_Ptr; First : Ada.Streams.Stream_element_Offset; Last : Ada.Streams.Stream_element_Offset; end record; There will be several buffers allocated/deallocated from a pool, so the reference is a part of the Buffer_Slice type. [cut] > > > Does this actually solve your problem, or am I missing something? It solves the problem, but exposes a bit more information to the clients than necessary. It is very easy for a client to address a slice outside the bounds: Buffer.Data (Buffer.First - 10 .. Buffer.Last + 15) But there is of course also the risk of over-engineering the buffer, so I will settle with the above design. > > -- > Nick Roberts - Mark Lorenzen