comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: new_line in a put_line
Date: Wed, 04 Dec 2002 17:15:40 +0100
Date: 2002-12-04T17:15:40+01:00	[thread overview]
Message-ID: <8d9suu4d65a91bu1qf9hl0eb9dpo2h8c02@4ax.com> (raw)
In-Reply-To: wccy97524gt.fsf@shell01.TheWorld.com

On Wed, 4 Dec 2002 15:23:14 GMT, Robert A Duff
<bobduff@shell01.TheWorld.com> wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> writes:
>
>> On 04 Dec 2002 10:31:15 +0100, Fraser Wilson
>> <newsfraser@blancolioni.org> wrote:
>> 
>> >Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> 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



  reply	other threads:[~2002-12-04 16:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-02  5:36 new_line in a put_line Vlad
2002-12-02  9:47 ` Preben Randhol
2002-12-02 17:04   ` Frank J. Lhota
2002-12-05 11:10     ` Preben Randhol
2002-12-02 10:14 ` Dmitry A. Kazakov
2002-12-02 14:57 ` Matthew Heaney
2002-12-03 11:33   ` Fraser Wilson
2002-12-03 15:01     ` Dmitry A. Kazakov
2002-12-04  9:31       ` Fraser Wilson
2002-12-04 14:10         ` Dmitry A. Kazakov
2002-12-04 15:23           ` Robert A Duff
2002-12-04 16:15             ` Dmitry A. Kazakov [this message]
2002-12-04 18:11               ` tmoran
2002-12-04 20:21                 ` Simon Wright
2002-12-05  9:36                 ` Dmitry A. Kazakov
2002-12-05 22:40                   ` tmoran
2002-12-04 15:25           ` Stephen Leake
2002-12-04 16:55             ` Jeffrey Carter
2002-12-04 17:24               ` Stephen Leake
2002-12-04 17:43               ` Warren W. Gay VE3WWG
2002-12-05  1:31                 ` Jeffrey Carter
2002-12-05 18:11                   ` Warren W. Gay VE3WWG
2002-12-02 15:49 ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2002-12-03 11:52 Grein, Christoph
2002-12-04  9:39 ` Fraser Wilson
2002-12-04 10:03 Grein, Christoph
2002-12-05  6:16 Grein, Christoph
2002-12-05  9:44 ` Dmitry A. Kazakov
2002-12-05  6:28 Grein, Christoph
2002-12-05 14:19 ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox