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 X-Google-Thread: 103376,ba19b629e3223dba,start X-Google-Attributes: gid103376,public From: Erik Margraf Subject: Q: Protected types and entries (long) Date: 1999/02/16 Message-ID: <36C98180.98296205@siemens.at>#1/1 X-Deja-AN: 444945125 Content-Transfer-Encoding: quoted-printable X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: news@siemens.at X-Trace: scesie13.sie.siemens.at 919175597 15224 195.3.42.108 (16 Feb 1999 14:33:17 GMT) Organization: Siemens AG Mime-Version: 1.0 NNTP-Posting-Date: 16 Feb 1999 14:33:17 GMT Newsgroups: comp.lang.ada Date: 1999-02-16T14:33:17+00:00 List-Id: Recently I started to learn about protected types. I tried to do = something like the following: (Not 100% Ada :-) =2E.. type buffer is array (...) of character; protected type Object is entry put (data : in buffer); private internal_buffer : array (BIG_Enough) of character; items_in_buffer : integer :=3D 0; end; = =2E.. protected Object body entry put (data : in buffer) = when data'size + items_in_buffer <=3D internal_buffer=B4size is begin ... end; end Object; Since the reference to a formal parameter of an entry is not allowed, gnat refused to compile this ;-). I changed the code to type buffer is array (...) of character; protected type Object is entry put (data : in buffer); private entry p_put (data : in buffer); internal_buffer : array (BIG_Enough) of character; data_size : integer; items_in_buffer : integer :=3D 0; end; = =2E.. protected Object body entry put (data : in buffer) = when true is begin data_size :=3D data=B4size; if data_size + items_in_buffer > internal_buffer=B4size then = requeue p_put; end if; end; entry p_put (data : in buffer) = when data_size + items_in_buffer <=3D internal_buffer=B4size is begin ... end; end Object; This compiles. = Now my questions: - Can someone tell me WHY this limitation in the barrier exists? - Is my "solution" really a solution to this problem? - (What) Should I do something different? Thanks Erik Margraf -- = -------------------------------------------------------------------- -- Erik Margraf -- Siemens Austria PSE KB2 -- erik.margraf@siemens.at -- +43 1 1707 45887 --------------------------------------------------------------------