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,f6f130eea077b8f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-22 01:03:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.algonet.se!algonet!newsfeed1.uni2.dk!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: 'Write attribute vs Write procedure. References: <7vk7ck7iwc.fsf@vlinux.voxelvision.no> From: Ole-Hjalmar Kristensen Message-ID: <7v1xyr76jv.fsf@vlinux.voxelvision.no> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 22 May 2003 08:02:28 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1053590548 193.216.12.150 (Thu, 22 May 2003 10:02:28 MET DST) NNTP-Posting-Date: Thu, 22 May 2003 10:02:28 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.ada:37631 Date: 2003-05-22T08:02:28+00:00 List-Id: Simon Wright writes: > Ole-Hjalmar Kristensen writes: > > > tmoran@acm.org writes: > > > > > > Write (This.Link.all, > > > > Buffer (1 .. Stream_element_offset (Chunk))); > > > > Stream_element_array'Write (This.Link, > > > > Buffer (1 .. Stream_element_offset (Chunk))); > > > >... > > > > the Write procedure is taking no noticeable amount of time/cpu. > > > >In the contrary, the 'Write attribute takes like 3-4 seconds of 100% CPU > > > Perhaps Gnat's 'Write is doing one 'Write(Stream_Element) call for > > > each element of the Buffer, vs a single call for the whole thing in > > > the procedure version? Since you've already got a Stream_Element_Array, > > > perhaps you could call > > > Ada.Streams.Write(Ada.Streams.Root_Stream_Type'class(This.Link), > > > Buffer (1 .. Stream_element_offset (Chunk))); > > > directly? > > > Personally, I think using the default 'write is only reasonable > > > in the very simplest cases. If something is big, or complicated, > > > I'd write my own 'write for it. > > > > Yes, but that removes much of the attraction of using a stream in the > > first place. It should only be necessary to do your own write if you > > wanted another representation of it in the external format. A prime > > example of rendering a very nice feature of the language pretty much > > unusable because of a poor implementation. > > ARM 13.13.2(9) says > > [...] For composite types, the Write or Read attribute for each > component is called in canonical order, which is last dimension > varying fastest for an array, and positional aggregate order for a > record. Bounds are not included in the stream if T is an array > type. [...] > > I'm not sure whether an implementation has licence to produce code > which works "as if" this happened. What about the exceptional cases? > (where there isn't enough room in the stream for all the elements, for > example). Too bad. But I cannot see what stops the compiler to produce code which works "as if" this happened in the case where every read/write attribute is compiler generated. After all, the standard does not specify how the compiler should implement read and write for elementary types. -- Ole-Hj. Kristensen ****************************************************************************** * C: You shoot yourself in the foot * Ada: If you are actually dumb enough to program in this language, the DOD will * kidnap you, stand you up in front of a firing squad, and tell the soldiers: * "Shoot at his feet" ******************************************************************************