[webkit-dev] unwritten rules of webkit style

Simon Fraser simon.fraser at apple.com
Wed Sep 2 10:36:01 PDT 2009


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090902/50abe7a0/attachment.html>


More information about the webkit-dev mailing list