comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Preferred way to do binray I/O on standard input/output stream
Date: Mon, 26 Oct 2009 19:36:49 -0700 (PDT)
Date: 2009-10-26T19:36:49-07:00	[thread overview]
Message-ID: <a558f6b4-8f4c-459d-8706-4eb8125dae1e@w19g2000yqk.googlegroups.com> (raw)
In-Reply-To: nospam-6E0089.21143826102009@news.aioe.org

On 27 oct, 02:14, "John B. Matthews" <nos...@nospam.invalid> wrote:
> with Ada.Text_IO; use Ada.Text_IO;
> with Ada.Text_IO.Text_Streams;
>
> procedure Copy is
>    Stream_Ptr : Text_Streams.Stream_Access;
>    C : Character;
> begin
>    Stream_Ptr := Text_Streams.Stream(Current_Input);
>    loop
>       Character'Read(Stream_Ptr, C);
>       Put(C);
>    end loop;
> exception
>    when End_Error => null;
> end Copy;
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>

The trouble with this, is that this force a look-ahead : an item must
be read to know if an item is available, and this can lead into
numerous logical traps (I prefer to keep distinct the action of
reading and testing availability of data).

May be this is finally really better to re-create a type to stand for
the standard input as binary, but what I do not like with this way, is
the possible lack of knowledge of some platforms, which is required
for implementations (For me, it will be OK for Windows, BSD, Linux,
but not the others... although in the mean time, I'm not sure I will
ever need it for other platforms).



  reply	other threads:[~2009-10-27  2:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-24 22:07 Preferred way to do binray I/O on standard input/output stream Hibou57 (Yannick Duchêne)
2009-10-24 22:57 ` Jeffrey R. Carter
2009-10-24 23:22   ` Hibou57 (Yannick Duchêne)
2009-10-27  0:34   ` Hibou57 (Yannick Duchêne)
2009-10-27  1:14     ` John B. Matthews
2009-10-27  2:36       ` Hibou57 (Yannick Duchêne) [this message]
2009-10-27 16:13         ` John B. Matthews
replies disabled

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