From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!6Wzk4cIOQzbtIfSd/aOQqg.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Accessing Addresses in a Passed String Date: Sat, 1 Jan 2022 20:23:40 +0100 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="58261"; posting-host="6Wzk4cIOQzbtIfSd/aOQqg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:63320 List-Id: On 2022-01-01 19:53, Pat Van Canada wrote: > in the declarative section, I can write: > > str2 : aliased string( 1 .. 4 ) ; > > and then I could potentially access the address of each character in the string. > > However, I cannot use "aliased" in an argument list and worse yet, since it is effectively a character array, it will be passed by pointer. You probably mean "by reference." It is not clear why do you care. > Here is a little snippet of what I am trying to do: > > procedure double_draw ( row : in integer ; > column : in integer ; > word : in out string ) is > > begin > > for j in column .. word'length loop > input_pad(row,j).ch_ptr := word(j)'access ; Looks like an attempt to produce a dangling pointer in Ada. Not an easy task. You certainly should never ever assign pointers to actual parameters unless you communicating with C. > This is not going to work, does anyone have a suggestion of how I might work around this? My only solution right now is to move this to the calling code and simply pass the address of each character of a string You should describe the actual problem not a [wrong] solution to it. If you want to reference inside a string you must declare a helper type. Typically one uses some reference counting handle to the string body and indices to the beginning and end of the slice. Though an access type would do as well, just unsafe. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de