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,a046ce7f5ee1fa51 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-04 08:15:42 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: new_line in a put_line Date: Wed, 04 Dec 2002 17:15:40 +0100 Message-ID: <8d9suu4d65a91bu1qf9hl0eb9dpo2h8c02@4ax.com> References: <1ec946d1.0212020657.2bd8b5c@posting.google.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1039018541 27227904 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:31425 Date: 2002-12-04T17:15:40+01:00 List-Id: On Wed, 4 Dec 2002 15:23:14 GMT, Robert A Duff wrote: >Dmitry A. Kazakov writes: > >> On 04 Dec 2002 10:31:15 +0100, Fraser Wilson >> wrote: >> >> >Dmitry A. Kazakov writes: >> > >> >> Just do not do I/O from them. Define a mutex as a protected object and >> >> a spin lock as a controlled type (less troubles with releasing a >> >> mutex): >> > >> >[..] >> > >> >> procedure Put_Line (Text : String) is >> >> Get_It : Lock (Write_Mutex'Access); >> >> begin >> >> Ada.Text_IO.Put_Line (Text); >> >> end Put_Line; >> > >> >Something inside me rebels at using side-effects from a declaration >> >like that. >> >> Right, right. It is also my opinion [there was a thread regarding this >> subject in c.l.a] that using unused (:-)) objects probably indicates a >> design problem. A task-based design might be better. > >There is nothing wrong with declaring a limited controlled object that >is used only for its Initialize/Finalize effects. It's a common idiom >in Ada (and also in C++). Right, it works and it is safe, but still to my taste it is a bad design because of using exclusively side-effects. >It's the *only* way in Ada to safely ensure that resources get cleaned >up -- so telling people not to use it is bad advice, IMHO. You mean controlled objects? Yes, I didn't argue against them. It is only that I do not like "pure" lock-objects [like Lock above], something tells me that there should be a better way. For instance, to fuse lock with a proxy object as in my example. >You could reasonably argue that Ada ought to have a better syntax for >this -- one that does not involve creating dummy types. In fact, such a >syntax was proposed as part of Ada 9X, but was rejected on the grounds >that limited controlled types provide all the necessary functionality. No that was a right decision, because it would change nothing, it would remain just a dressed side effect. The problem as I see it, is of course that one tries to express a CRITICAL SECTION in terms of OBJECTS. This *cannot* be good. The first is about execution flow control the second is about data. Only OO fundamentalists believe that objects is everything that one might wish. (:-)) >A task-based design would work just fine, too. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de