comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Ensuring resource cleanup
Date: Mon, 08 Feb 2010 15:16:12 +0100
Date: 2010-02-08T15:16:12+01:00	[thread overview]
Message-ID: <87zl3jertf.fsf@mid.deneb.enyo.de> (raw)

It looks as if I might need to do some Ada maintenance programming
soon.  I can use the GNAT from GCC 4.3.

Are there any new ways to ensure resource cleanup?

I tried to use Ada.Finalization.Limited_Controlled in the past, but
there were several issues with it: there was some run-time overhead
(because of the tag and because the finalizer is abort-deferred, which
seemed to defeat inlining and scalar replacement of aggregates), it
was impossible to instantiate generics containing such types below the
library level, and having multiple different types inherting from
Limited_Controled in the same package often resulted in multi-dispatch
errors (and using 'Class required exposing the tagged nature of the
type in the interface, with has other drawbacks).

Explicit cleanup using cleanup subprograms is okay, too, provided that
there is some tool to ensure that they are used properly.  This is
despite the rather cumbersome syntax:

  declare
     X : Object;
  
  begin
     Init (X);
     begin
        Make_Use_Of (X);
     exception
        when others =>
           Cleanup (X);
           raise;
     end;
     Cleanup (X);
  end;

But I'd really have a tool that ensures that Init and Cleanup calls
are properly paired in this way.

Are there other approaches I don't know about yet?



             reply	other threads:[~2010-02-08 14:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 14:16 Florian Weimer [this message]
2010-02-08 15:29 ` Ensuring resource cleanup Jean-Pierre Rosen
2010-02-08 15:31 ` Robert A Duff
2010-02-08 16:01   ` Florian Weimer
2010-02-08 16:18     ` Robert A Duff
2010-02-08 18:30       ` Florian Weimer
2010-02-08 20:47         ` Robert A Duff
replies disabled

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