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!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.xdsl-89-0-114-118.netcologne.de!not-for-mail From: Frank Buss Newsgroups: comp.lang.ada Subject: Re: how to use "in out" for the "self" parameter in a function in a protected object? Date: Sun, 17 Sep 2017 00:40:12 +0200 Organization: news.netcologne.de Distribution: world Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 16 Sep 2017 22:40:12 +0000 (UTC) Injection-Info: newsreader4.netcologne.de; posting-host="xdsl-89-0-114-118.netcologne.de:89.0.114.118"; logging-data="31014"; mail-complaints-to="abuse@netcologne.de" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: X-Received-Body-CRC: 2303693349 Xref: news.eternal-september.org comp.lang.ada:48160 Date: 2017-09-17T00:40:12+02:00 List-Id: On 09/17/2017 12:02 AM, Jeffrey R. Carter wrote: > On 09/16/2017 10:47 PM, Frank Buss wrote: >> I have a function in a protected object, which needs to change a >> variable, but I get this error: >> >> actual for "Self" must be a variable > > There's no Self in the code you posted, so I can't really say. Yes, this is strange. I guess this is the parameter for the call inside the function, which is named "Self" and declared as "in out". > However, a protected function is not allowed to change the state of > the protected object. What's the rationale for this behavior and where can I find the definition, that it is not allowed? Doesn't look useful to me, because I can do this with a procedure. In fact now I have written a procedure with an "out" parameter and it works. But it is annoying to declare an extra temporary variable for it when I call it. Would be nice, if I could do this with a function. There is no such limitation when I use a tagged type, as you can see for the "Self" parameter in the Ringbuffer package I wrote earlier, see here: https://groups.google.com/d/msg/comp.lang.ada/HXrcX2w8qpQ/I7Uw12BaAwAJ This looks inconsistent to me. At least it should be possible to change the behavior, if the default is only "in". -- Frank Buss, http://www.frank-buss.de electronics and more: http://www.youtube.com/user/frankbuss