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!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Taking 'Access of single task/protected object Date: Thu, 7 Jan 2016 18:30:54 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: LNA1TkTuMxfwTHzeJdi6nA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:29045 Date: 2016-01-07T18:30:54+01:00 List-Id: On 2016-01-07 17:18, G.B. wrote: > It seems impossible to take the 'Access (or 'Unchecked_Access) > of a single task object, since it cannot be made aliased. > And, I guess, as it is not of a named type, so that there > is no way to express even an anonymous access type. > > This is, I think, the crucial bit of a question (34540199) > asked at stackoverflow. (The example uses some listener pattern > which looks like Java written in Ada, but that's not why I'm > asking.) > > task Single is > entry Something; > end Single; > > ...some_context (access_discriminant => Single'Access)... It does not make sense because you cannot declare a discriminant without mentioning the task type. Therefore it cannot be anonymous. [ I leave aside the question if anonymous task/protected object types should be allowed: type T (Reference : access task is entry Something; end) is ... Ada's degradation has not reached this low, yet? ] > So, suppose some_context requires indirect access to a single > task object, i.e., to one of an anonymous task type. > Is there a preferred solution to single-task vs. multiple > references? task type Single is entry Something; end Single; ... Object : aliased Single; ... type T (Reference : not null access Single) is ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de