comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: A suggestion for resource management
Date: Sat, 21 Aug 2010 23:09:38 +0200
Date: 2010-08-21T23:09:38+02:00	[thread overview]
Message-ID: <8739u73c6l.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: 18bfxkfl1kjy0$.4vebp50shxrp$.dlg@40tude.net

* Dmitry A. Kazakov:

>> You can't always change libraries in that way.  Adding destructors has
>> both syntactic and run-time overhead.
>
> I don't see why. Without class-wide objects there is no overhead,
> everything is statically known.

You need escape analysis or inter-procedural scalar replacement to
eliminate the tag.  But it certainly can be done, and the additional
word will not hurt in all but the most extreme cases.

(There's a GNAT-specific inefficiency, but it is reportedly being
tackled.)

> BTW, file handle File_Type should not be opened, it should be
> constructed. There should be no invalid File_Type,

There are cases where you need the explicit Close operation, so you
still end up with an invalid state.

How would you handle an exception raised by construction, without
extending the handler to cover undue regions of code?

>> There are some cases where the destructor solution doesn't really
>> apply.  For instance, the cleanup operation might need two parameters,
>> one denoting the object, and a second one decribing where to put it.
>
> I would use mix-in in such rare cases. However, I try to avoid clean-ups.
> It is a bad pattern.

And you suggest to use Finalize procedures instead?  Hmm.



  reply	other threads:[~2010-08-21 21:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-21 16:20 A suggestion for resource management Florian Weimer
2010-08-21 19:07 ` Dmitry A. Kazakov
2010-08-21 19:47   ` Florian Weimer
2010-08-21 20:53     ` Dmitry A. Kazakov
2010-08-21 21:09       ` Florian Weimer [this message]
2010-08-22  6:40         ` Dmitry A. Kazakov
2010-08-23 23:22         ` Randy Brukardt
2010-08-21 20:34 ` Niklas Holsti
2010-08-21 21:01   ` Florian Weimer
2010-08-22 10:53     ` Niklas Holsti
2010-08-22 15:29       ` Florian Weimer
2010-08-22 16:12       ` Florian Weimer
2010-08-23 12:25         ` Niklas Holsti
2010-09-04 19:09           ` Florian Weimer
2010-09-07 10:14             ` Niklas Holsti
2010-08-22 11:32     ` Georg Bauhaus
2010-08-23 23:37       ` Randy Brukardt
2010-08-22 13:09 ` stefan-lucks
2010-08-22 14:30   ` Florian Weimer
2010-08-22 15:09   ` Florian Weimer
replies disabled

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