comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: variable length strings
Date: Thu, 28 Oct 2004 10:14:19 +0200
Date: 2004-10-28T10:14:19+02:00	[thread overview]
Message-ID: <1ok9c1htwcrmd.dta4w50brarb.dlg@40tude.net> (raw)
In-Reply-To: uekjkktfe.fsf@obry.org

On 27 Oct 2004 18:38:29 +0200, Pascal Obry wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> But the existing Get_Line does not reaches the goal either. Normally it is
>> used with the buffer allocated on the stack. So it is the stack again.
> 
> That's wrong!
> 
>    procedure Get_Line(Item : out String; Last : out Natural);
> 
> The buffer is bounded in this case, it's up to you to read a chunk of data
> (using a small buffer on the stack) and do whatever is needed with it. So I
> see not problem with the standard Get_Line.

You (Get_Line) just push the problem to the user, who will write:

declare
   Buffer : String (1..?);
   Length : Integer;
begin
   Get_Line (Buffer, Length);

1) Buffer is on the stack. 2) Its upper bound is unknown except for very
rare cases. The requirements usually as helpful as "it should work with
reasonable files". Go figure out the upper bound!

As for chunks of data, this is well another story. Note, if the parsing
methods allow arbitrary splitting the lines <=> it can work with character
stream <=> you need no Get_Line, the appropriate method is:

procedure Get(Item : out Character); 

> I never said that you can't use
> the stack, just that using a buggy Get_Line implementation as proposed here
> could heat too much stack space and is therefore unsafe.

I agree that it is a problem, but it is not the Get_Line's one. It is a
more general language issue, which probably should be answered in the
future. We cannot just dismiss T'Class, unconstrained containers etc. An
ability to deal with them (on the stack) is quite important. It is also a
question what compromises safety more: use of pointers or potential stack
overflow. For large projects, I would say it is definitively pointers.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2004-10-28  8:14 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-21 17:52 variable lenght strings fabio de francesco
2004-10-21 21:22 ` Martin Dowie
2004-10-21 22:42 ` Marius Amado Alves
2004-10-21 23:14   ` Matthew Heaney
2004-10-22  7:38     ` Martin Krischik
2004-10-22 12:30     ` fabio de francesco
2004-10-22  7:29   ` Martin Krischik
2004-10-22 13:01     ` Matthew Heaney
2004-10-24 15:46       ` Martin Krischik
2004-10-24 19:54         ` Jeffrey Carter
2004-10-24 21:30           ` Larry Kilgallen
2004-10-25  4:02             ` Jeffrey Carter
2004-10-21 23:01 ` Marius Amado Alves
2004-10-21 23:05 ` Stephen Leake
2004-10-22  7:25 ` Martin Krischik
2004-10-22 11:11   ` Martin Dowie
2004-10-24 15:43     ` Martin Krischik
2004-10-24 17:39       ` Martin Dowie
2004-10-24 18:37       ` Björn Persson
2004-10-25  7:30         ` Martin Krischik
2004-10-26  0:06           ` Randy Brukardt
2004-10-26  1:53             ` Larry Kilgallen
2004-10-26  8:49               ` Martin Krischik
2004-10-26 11:18               ` Marius Amado Alves
2004-10-26 12:48                 ` variable length strings Larry Kilgallen
2004-10-26 16:11                   ` Warren W. Gay VE3WWG
2004-10-26 18:50                     ` Björn Persson
2004-10-26 19:46                       ` Larry Kilgallen
2004-10-26  8:43             ` variable lenght strings Jean-Pierre Rosen
2004-10-26 13:15               ` Martin Krischik
2004-10-26 17:37                 ` Pascal Obry
2004-10-26 18:07                   ` Hyman Rosen
2004-10-26 20:10                     ` Pascal Obry
2004-10-27 10:26                       ` variable length strings Jacob Sparre Andersen
2004-10-27 10:39                         ` Pascal Obry
2004-10-27 11:47                         ` Larry Kilgallen
2004-10-28  7:18                           ` Jacob Sparre Andersen
2004-10-27 11:50                         ` Larry Kilgallen
     [not found]                         ` <uwtxcla1n.fsf@obry.Organization: LJK Software <PTzuwe3GsIg6@eisner.encompasserve.org>
2004-10-27 12:12                           ` Samuel Tardieu
2004-10-27 12:58                             ` Pascal Obry
2004-10-27 13:04                           ` Pascal Obry
2004-10-27 14:54                             ` Dmitry A. Kazakov
2004-10-27 16:38                               ` Pascal Obry
2004-10-28  8:14                                 ` Dmitry A. Kazakov [this message]
2004-10-28  8:49                                   ` Pascal Obry
2004-10-28  9:06                                     ` Dmitry A. Kazakov
2004-10-28 16:07                                       ` Pascal Obry
2004-10-28 22:05                                         ` Jeffrey Carter
2004-10-28 22:41                                           ` Randy Brukardt
2004-10-29  1:11                                             ` Jeffrey Carter
2004-10-29  7:42                                         ` Dmitry A. Kazakov
2004-10-28 10:31                         ` Larry Kilgallen
2004-10-26 18:13                   ` variable lenght strings Martin Krischik
2004-10-27 12:01                 ` Jean-Pierre Rosen
2004-10-26 17:46             ` Jeffrey Carter
2004-10-28 22:50               ` Randy Brukardt
2004-10-28 23:01                 ` Larry Kilgallen
2004-10-29 21:52                   ` Randy Brukardt
2004-10-29  8:48                 ` Dale Stanbrough
2004-10-29  9:11                   ` Larry Kilgallen
2004-10-24 18:38     ` Why these "Drop" parameters? (was: variable lenght strings) Björn Persson
2004-10-26  0:13       ` Randy Brukardt
2004-11-01  1:02         ` Why these "Drop" parameters? Björn Persson
2004-11-01 19:59           ` Randy Brukardt
2004-10-24 18:57 ` variable lenght strings Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
1989-06-04  7:03 Variable Length strings "Jonathan B. Owen"
1989-06-02 16:19 Variable Length Strings Thomas Hoyt
1989-06-02 13:26 "Jonathan B. Owen"
1989-06-06 13:19 ` Paul Warren
1989-05-30 15:39 Variable length strings Thomas Hoyt
replies disabled

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