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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e9caf8720058dd5e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!n76g2000hsh.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: embed accept statement in procedures not possible? Date: 4 May 2007 12:45:01 -0700 Organization: http://groups.google.com Message-ID: <1178307901.263809.221480@n76g2000hsh.googlegroups.com> References: <1178291081.936739.131740@c35g2000hsg.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1178307901 22952 127.0.0.1 (4 May 2007 19:45:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 May 2007 19:45:01 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: n76g2000hsh.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:15536 Date: 2007-05-04T12:45:01-07:00 List-Id: On May 4, 9:58 am, Jean-Pierre Rosen wrote: > Gerd a =E9crit : > > > My code (schematic only): > > > task t is > > entry e; > > end t; > > > task body t is > > procedure p is > > begin > > accept e; > > end p; > > begin > > p; > > end t; > > > GNAT tells me: "enclosing body for accept must be a task". But - the > > accept in procedure p _is_ in a task. So why is this not allowed? > > True. An accept statement must be *immediately* within a task body, not > in anything enclosed in the task body. > > That rule is necessary to ensure that a task can accept only its own > entries. Your example is of course very simple, but consider that a task > can be included in another task. What if Inner_Task called your P procedu= re? Actually, though, why is a syntactic rule necessary (as opposed to a run-time check)? Not that I'm proposing a language change. This is an area I haven't really given any thought, so I can't say whether the restriction that prevents "accept" from being done inside a procedure makes life too burdensome. But would there be any serious difficulty in changing the rules so that an "accept" statement is legal inside a procedure, but raises an exception if the statement is executed under the control of a task other than the one whose entry is being accepted? Off the top of my head (and after about six seconds' worth of thought), I don't see why this would be unfeasible. -- Adam