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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6009c73a58f787a0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-15 07:37:24 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: How to avoid unreferenced objects (mutexes etc) Date: Tue, 15 Jan 2002 10:41:58 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3c3ee8c8.105408250@News.CIS.DFN.DE> <3c429d1c.2624281@News.CIS.DFN.DE> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:18933 Date: 2002-01-15T10:41:58-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:3c429d1c.2624281@News.CIS.DFN.DE... > Absolutely. So my suspicion goes. Or else, there must be something > fundamentally wrong [in design] if unused objects are *really* > required. It clearly indicates a *problem*. The problem is that the language doesn't have a termination handler for blocks, a la a "finally" clause in Java or Win32 Structured Exception Handling. So you have to create "unused" objects as a work-around. > A "natural" solution would be to extend monitors, but alas tasks > are not tagged. Can't you parameterize a task with an access discriminant that binds to an object whose type is class-wide, and then call (dispatching) operations on that object? type T is tagged limited null record; procedure Op (O : access T); task Task_Object (O : access T'Class) is .. task body Task_Object is begin ... Op (O); --dispatching call to object viewed thru access discrim ... end; Now you're free to derive types from T, and bind derived type instances to a task. Using this idiom obviates the need for extensible task types. > So I chose the lesser evil = mutexes with all that nasty problems of > error recovery, you have pointed. I really do not like it. The language gives you primitives so that you can use to build in the safety. There is no problem using semaphores in Ada95, if you follow certain idioms.