comp.lang.ada
 help / color / mirror / Atom feed
From: Ole-Hjalmar Kristensen <oleh@vlinux.voxelvision.no>
Subject: Re: 'Write attribute vs Write procedure.
Date: Thu, 22 May 2003 08:02:28 GMT
Date: 2003-05-22T08:02:28+00:00	[thread overview]
Message-ID: <7v1xyr76jv.fsf@vlinux.voxelvision.no> (raw)
In-Reply-To: x7v65o4j8y4.fsf@smaug.pushface.org

Simon Wright <simon@pushface.org> writes:

> Ole-Hjalmar Kristensen <oleh@vlinux.voxelvision.no> 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"
******************************************************************************



  reply	other threads:[~2003-05-22  8:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-21  0:07 'Write attribute vs Write procedure Jano
2003-05-21  0:42 ` tmoran
2003-05-21  7:48   ` Ole-Hjalmar Kristensen
2003-05-21  9:23   ` Ole-Hjalmar Kristensen
2003-05-21 16:22     ` tmoran
2003-05-22  7:51       ` Ole-Hjalmar Kristensen
2003-05-21 16:24     ` tmoran
2003-05-21 21:17     ` Simon Wright
2003-05-22  8:02       ` Ole-Hjalmar Kristensen [this message]
2003-05-22 13:49       ` Marc A. Criley
2003-05-22 20:07         ` Simon Wright
2003-05-23  6:09   ` Craig Carey
2003-05-23 19:55     ` Simon Wright
2003-05-23 20:48       ` AI-248 and counting the elements in an external file Larry Kilgallen
2003-05-23 21:12         ` Stephen Leake
2003-05-23 21:45           ` Randy Brukardt
2003-05-24  1:45             ` Larry Kilgallen
2003-05-24 22:00               ` Robert I. Eachus
2003-05-25  3:54                 ` Larry Kilgallen
2003-05-27 20:19                   ` Randy Brukardt
2003-05-27 20:57                     ` Larry Kilgallen
2003-05-28 18:26                       ` Randy Brukardt
2003-05-24  1:42           ` Larry Kilgallen
2003-05-28 21:17             ` Brian Gaffney
2003-05-28 22:06               ` Larry Kilgallen
2003-05-24 14:11 ` 'Write attribute vs Write procedure Craig Carey
replies disabled

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