From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Substrings as argument to procedures/functions Date: Wed, 13 Apr 2016 09:19:47 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <2055a188-fb5f-496a-ab37-b25d81cebe1b@googlegroups.com> <5271bc70-bfea-4e2f-b4e3-6c847843f5b4@googlegroups.com> NNTP-Posting-Host: bqgfK7NL3xTHnr0WRaLl4g.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:30089 Date: 2016-04-13T09:19:47+02:00 List-Id: 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