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!weretis.net!feeder4.news.weretis.net!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: how to use "in out" for the "self" parameter in a function in a protected object? Date: Sat, 16 Sep 2017 22:47:38 +0200 Organization: news.netcologne.de Distribution: world Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 16 Sep 2017 20:47:40 +0000 (UTC) Injection-Info: newsreader4.netcologne.de; posting-host="xdsl-89-0-114-118.netcologne.de:89.0.114.118"; logging-data="26163"; mail-complaints-to="abuse@netcologne.de" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 X-Mozilla-News-Host: news://news.netcologne.de:119 Xref: news.eternal-september.org comp.lang.ada:48157 Date: 2017-09-16T22:47:38+02:00 List-Id: 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 I assume the reason is, that the implicit "self" parameter for my function is declared as "in" and not "in out". How can I change it to "in out"? Below is the code. The function "Available" for example works, but the function "Read" causes the error when compiling. Both are accessing the FIFO variable, "Available" only with a call where the variable is used as an "in" parameter, but for "Read" I call a function where it is passed as an "in out" parameter. with Interfaces; use Interfaces; with Ada.Interrupts; use Ada.Interrupts; with Ada.Interrupts.Names; use Ada.Interrupts.Names; with STM32.USARTs; use STM32.USARTs; with Ringbuffers; package Serial_IO is package FIFO_Package is new Ringbuffers(256, Unsigned_8); subtype FIFO is FIFO_Package.Ringbuffer; protected type Serial_Port_Controller is procedure Init (Baud_Rate: Baud_Rates); function Available return Boolean; function Read return Unsigned_8; procedure Write (Data : Unsigned_8); private procedure Interrupt_Handler; pragma Attach_Handler (Interrupt_Handler, USART1_Interrupt); Input : FIFO; Output: FIFO; Initialized : Boolean := False; end Serial_Port_Controller; Serial : Serial_Port_Controller; end Serial_IO; -- Frank Buss, http://www.frank-buss.de electronics and more: http://www.youtube.com/user/frankbuss