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

Re: [MiNT] Programming style



--------------------------------------------------
From: "Vincent Rivière" <vincent.riviere@freesbee.fr>
Sent: Tuesday, December 15, 2009 2:55 PM
Cc: "[MiNT] Mailing-List" <mint@fishpool.com>
Subject: Re: [MiNT] Programming style

Global variables are bad, because the cause reentrency problems.

I'm fully aware of the reentrancy-issue, but often reentrancy is not needed or desired. I find the hidden dependancy between functions that are using global variables a bigger problem when maintaining code.

Static variables defined inside functions are again a bit less bad, because they are accessible only inside their function. However they are still hidden global variables, and the reentrency problems are still here.

It is not a problem when the function is not supposed to be re-entrant ;-)

Personally, when I absolutely need some kind of global variable, I prefer using a static variable inside a function, the source is cleaner.

In this case I need to remember the state of the deadkey between calls to the keyboard handler, so without rewriting the whole thing I'm afraid that the static variable would have to stay there.

Jo Even

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4689 (20091215) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com