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=2.1 required=5.0 tests=BAYES_40,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f2ce122bf6177acb,start X-Google-Attributes: gid103376,public From: aic001@teix.uib.es (SAD KAT) Subject: protected types in Ada95 Date: 1997/09/07 Message-ID: <5uui32$dhg@alf01.uib.es>#1/1 X-Deja-AN: 271212660 Organization: Universitat de les Illes Balears, Balearic Islands. Reply-To: aic001@teix.uib.es Newsgroups: comp.lang.ada Date: 1997-09-07T00:00:00+00:00 List-Id: Hi, I have a program with differents tasks reading and writting data. I have read that I have to protect my data to be sure that the values are the correct ones, to keep a exclussive access to them. I've done a think like that: package data_pac is type type_of_var is record -- here are the description end record; protected type type_of_var_prot is function read_var return integer; procedure write_var (item : in type_of_var); private var2 : type_of_var; end type_of_var_prot; end data_pac; package body data_pac is protected type type_of_var_prot is function read_var return integer is begin -- body of the function end read_var; procedure write_var (item : in type_of_var) is begin -- body of the procedure end write_var; end type_of_var_prot; begin null; end data_proc; The compiler shows that message : "subprogram body not allowed here" and I don't knwo where's thw mistake. I have also another doubt, how do I have to use the function read_var and the procedure write_var? I mean, if I have in the main package: procedure main is data_a : type_of_var; data_b : type_of_var_prot; begin get(data_a); data_b.write_var(data_a); -- rest of program end main; Is this correct? Thanks for helping and please forgive my poor English, mailto: sadkat@hotmail.com mailto: aic001@teix.uib.es Joan Andreu Juan Torrens (Illes Balears, SPAIN)