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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,770f689069566e46 X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: protected types and functions in Ada95 (Newbie) Date: 1997/04/24 Message-ID: #1/1 X-Deja-AN: 237240032 Distribution: world References: <335F2DF6.827@und.ida.liu.se> Organization: PSI Public Usenet Link Newsgroups: comp.lang.ada Date: 1997-04-24T00:00:00+00:00 List-Id: In article <335F2DF6.827@und.ida.liu.se> Magnus Therning writes: > I want to seize a semaphore in a function. Is that possible using the > following protected type semaphore? Functions can only take 'in' > parameters, but I need 'in out' since Seize changes the semaphore. > > package Semaphore_S is > > type Kind(Num : Integer := 1) is limited private; > > procedure Seize(Sem : in out Kind); > procedure Release(Sem : in out Kind); I suppose the thing to do is to use access parameters. How do you feel about this: procedure Seize(Sem : access Kind); ... somewhere else... function F ( Sem : access Kind ) return ... is ... Seize(Sem); ... end F; /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com