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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,60d761814c33393c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-10 10:55:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Qs re 'Write & 'Read Date: Tue, 10 Jun 2003 12:55:37 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:38919 Date: 2003-06-10T12:55:37-05:00 List-Id: wrote in message news:YDeFa.929408$Zo.212966@sccrnsc03... > Is the default 'Write on a non null access type supposed to write the .all > and a 'Read supposed to do an allocate and read in the .all value? > Same questions for generall access types. No. The actual access value is written to the stream -- not very useful. However, I have been using stream attribute override procedures like these for years: ----------------------------- -- Translation_Access_Read -- ----------------------------- procedure Translation_Access_Read (The_Stream_Access : access Ada.Streams.Root_Stream_Type'Class; The_Translation_Access : out Translation_Access) is Is_Non_Null : Boolean; begin Boolean'Read (The_Stream_Access, Is_Non_Null); if Is_Non_Null then The_Translation_Access := new Translation' (Translation'Input (The_Stream_Access)); else The_Translation_Access := null; end if; end Translation_Access_Read; ------------------------------ -- Translation_Access_Write -- ------------------------------ procedure Translation_Access_Write (The_Stream_Access : access Ada.Streams.Root_Stream_Type'Class; The_Translation_Access : Translation_Access) is begin if The_Translation_Access /= null then Boolean'Write (The_Stream_Access, True); Translation'Output (The_Stream_Access, The_Translation_Access.all); else Boolean'Write (The_Stream_Access, False); end if; end Translation_Access_Write; The idea is that in a similar fashion to the way that for unconstrained string types the string itself is preceded by its contstraint, access types are written to the stream with a boolean value preceding the data (if any). It surely seemed to me like the language standard could have defined something like this as the default for access types, but alas, it did not. I'm not sure why i didn't make these procedures as part of a generic package to be instantiated with two parameters -- the data type and its access type, but this is what I've been using, lo these several years. > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >