comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Streams in GNAT 3.14p
Date: Wed, 12 Jun 2002 10:43:56 +0200
Date: 2002-06-12T10:43:56+02:00	[thread overview]
Message-ID: <460egugo809clqrijsgq4cba6jcbuavkv6@4ax.com> (raw)
In-Reply-To: 4519e058.0206101114.4b8dfd2f@posting.google.com

On 10 Jun 2002 12:14:41 -0700, dennison@telepath.com (Ted Dennison)
wrote:

>Dmitry A.Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<ae295a$3b12g$1@ID-77047.news.dfncis.de>...
>> Hi!
>> 
>> Recently I found that GNAT 3.14p implementation of streams looks a bit 
>> strange. When a tagged object is written (S'Class'Output), then 
>> Write(Stream, Item) is called for each character of the external 
>> representation of tag _separately_. For types declared in deeply nested 
>> child packages it is about 100 separate calls.
>
>That's the way String'Output (and any other array 'Output) works by
>default. I suppose they could have optimized it for tag strings
>without running afowl of the ARM, but it isn't horribly suprising that
>they didn't.

I think that a possible way to make Streams usable for internal
communication could be [in the future standard] to declare two
dispatching operations for Root_Stream_Type dealing with tags:

procedure Output (Stream : access Root_Stream_Type; Type_Tag : Tag); 
function Input (Stream : access Root_Stream_Type) return Tag; 

They use Ada.Tags.External_Tag/Internal_Tag if not overridden. Then a
user could override them with something like:

procedure Output
   (Stream : access Local_Memory_Stream; Type_Tag : Tag) is
begin
   Tag'Output (Stream, Type_Tag);
end Output;

function Input (Stream : access Local_Memory_Stream) return Tag is
begin
   return Tag'Input (Stream);
end Input;

Of course Tag'Input and Tag'Output should have reasonable
implementations, i.e. input/output tags as-is.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2002-06-12  8:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-11  1:24 Streams in GNAT 3.14p Dmitry A.Kazakov
2002-06-10 19:14 ` Ted Dennison
2002-06-12  8:43   ` Dmitry A. Kazakov [this message]
2002-06-12 19:50     ` Randy Brukardt
replies disabled

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