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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6c8d87b37a287813 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsout01.versatel.de!newsin01.versatel.de!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: De-serializing and stack sizes Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4lrakfF3b2jqU1@individual.net> Date: Sat, 2 Sep 2006 10:14:12 +0200 Message-ID: <71n306fev9s3$.12vqt5uyk5bak.dlg@40tude.net> NNTP-Posting-Date: 02 Sep 2006 10:13:35 CEST NNTP-Posting-Host: 6383f386.newsspool1.arcor-online.net X-Trace: DXC=]F\ISM2gI]l016@cHD@m;jic==]BZ:afn4Fo<]lROoRagUcjd<3m<;bg>ib83h:^Oh[6LHn;2LCVn[ On Fri, 01 Sep 2006 19:57:55 +0200, Alex R. Mosteo wrote: > I'm now facing a problem that I don't know how to solve. I'm going to give > some thought to it over the week-end and any ideas are welcome. > > I have some objects that I want to serialize to files. For their creation I > use access types so they get created in heap and there's no problem. I > simply output them with > > Item_Type'Output (Stream, Item.all); > > However, you see the problem, loading them back is a no-no: > > Item : constant Item_Access := new Item_Type'(Item_Type'Input (Stream)); > > The 'Input attribute is trying to return the object in the stack and so it > doesn't work. My items are around 20 MB in size (now, they could grow > bigger) and I'd like not to have to raise my stack to these sizes (also > making it doable from the environment task would be a plus). I think what you have is stream attributes for *limited* types. You didn't declare Item_Type limited, but in fact it is, because you want to prevent copying it, for example, from the stack to the heap. As we know it didn't work in Ada 95. It must be different in Ada 05. For Ada 95, in an analogous case, I wrote a limited types factory of my own. It was necessary anyway, because stream attributes are not portable. There are clear disadvantages of such approach (again for Ada 95), because of single inheritance. In Ada 05, it should be much better, because the number of ancestors is unlimited as long as they are interfaces. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de