[webkit-dev] unwritten rules of webkit style

Zoltan Herczeg zherczeg at inf.u-szeged.hu
Wed Sep 2 11:05:43 PDT 2009


Hi,

I am actually working on a patch which can frees global variables before
the program exit. https://bugs.webkit.org/show_bug.cgi?id=27980 As you can
see in the current patch, a standard naming convention is not really used
for global variables (I have to change the types for all of them). They
can sometimes written like a member name (defaultStyle), or a 'g'
(gNameCache) prefix. For static members sometimes an 's_' prefix is used
(s_styleNotYetAvailable), sometimes nothing (nullBaseString). If you wish,
I can do the renaming to something standardized along with the patch.

Zoltan

> On Sep 2, 2009, at 9:59 AM, Yong Li wrote:
>
>> I think global variables should start with "g_".
>>
>> -Yong
>
> I actually agree fairly strongly that constants and global/static
> variables should have consistent, identifiable prefixes.
>
> For globals, having a prefix code easier to understand with a quick
> scan. If the global has no prefix, you have to search for it and
> discover that it's not a local variable, member variable or parameter
> before understanding where it comes from. This is a particular problem
> in Xcode, which does not use a different syntax highlight color for
> globals (unlike the venerable CodeWarrior). I also think that globals
> are a particular concern because they impact thread safety, and
> misunderstanding their scope of influence can have bad ramifications.
>
> Using a prefix for constants also reduces brainprint when scanning
> code; you know that its value is never going to change.
>
> Simon
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>



More information about the webkit-dev mailing list