Re: [Vala] Singleton and reference count



On Thu, 2010-04-29 at 18:55 +0200, Jan Hudec wrote:
Hello,

On Wed, April 28, 2010 13:46, Jan Niklas Hasse wrote:
On Wed, Apr 28, 2010 at 11:31 AM, pancake <pancake youterm com> wrote:
On Apr 28, 2010, at 10:24 AM, Jan Niklas Hasse <jhasse gmail com> wrote:

So shouldn't Vala unref namespace scoped variables when leaving their
scope?

IMHO there is no reason to do it. The compiler could do it (using the
atexit mechanism) but than there are many ways the process can terminate
without calling them anyway (calling _exit, receiving fatal signal, the power
going out etc.). Therefore the program shouldn't rely on them for anything
important anyway and since system will clean up resources anyway, they are
not needed for that either. So IMHO supporting them would just promote
unreliable code and is thus not worth doing.


This is an important feature, and I don't see how it promotes unreliable
code.

In the event that the program terminates normally, libraries and
globally defined objects should be destroyed properly. That way they can
flush buffers, or terminate network connections cleanly. Isn't that the
point of the RAII pattern?

When a program is killed (or otherwise terminates abnormally) it is a
special case, and needn't be handled by the compiler.  I don't see a
problem using atexit to implement this feature.

IMHO vala should try and be as consistent as possible, and having to
manually destroy global variables is not consistent with the rest of
vala's memory management.

Attachment: smime.p7s
Description: S/MIME cryptographic signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]