comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Substrings as argument to procedures/functions
Date: Wed, 13 Apr 2016 09:19:47 +0200
Date: 2016-04-13T09:19:47+02:00	[thread overview]
Message-ID: <nekrvc$f68$1@gioia.aioe.org> (raw)
In-Reply-To: 5271bc70-bfea-4e2f-b4e3-6c847843f5b4@googlegroups.com

On 13/04/2016 06:44, reinkor wrote:
> Yes, I may somehow have confused index and position.
> However, there may be some security/paranoia reasons to minimize the
> information handed over to a subroutine?

How is that insecure not to know array bounds? It is all about contracts.

Consider Ada.Stream_IO. It has the procedure Read

    procedure Read (File : in  File_Type;
                     Item : out Stream_Element_Array;
                     Last : out Stream_Element_Offset);

With indices sliding there would be no way to implement it. Consider a call:

    Read (Buffer (From..Buffer'Last), To);

How could Read know what was From at the caller side?

You probably could redesign all interfaces in terms of positions, but 
then it will be heavy burden on the client's side, and very error-prone 
for the client to translate returned positions back to indices.

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

  reply	other threads:[~2016-04-13  7:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12  8:25 Substrings as argument to procedures/functions reinkor
2016-04-12  9:01 ` Dmitry A. Kazakov
2016-04-12 16:55   ` reinkor
2016-04-12 18:37     ` Dmitry A. Kazakov
2016-04-13  4:44       ` reinkor
2016-04-13  7:19         ` Dmitry A. Kazakov [this message]
2016-04-13 10:16         ` Brian Drummond
2016-04-13 11:43           ` reinkor
2016-04-13 11:54             ` Pascal Obry
2016-04-13 12:30               ` Mart van de Wege
2016-04-13 12:47                 ` Egil H H
2016-04-13 13:19                   ` Mart van de Wege
2016-04-13 16:57                 ` Jeffrey R. Carter
2016-04-12 18:17 ` Robert A Duff
2016-04-12 18:34 ` Jeffrey R. Carter
2016-04-13 21:29   ` Randy Brukardt
2016-04-25 15:33     ` rieachus
2016-04-25 22:07       ` Randy Brukardt
2016-04-26  6:12         ` Georg Bauhaus
2016-04-26 18:41           ` Randy Brukardt
2016-04-13 11:22 ` G.B.
replies disabled

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