Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8252567

HotSpot Style Guide should recommend naming conventions for macros

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 16
    • hotspot

      Neither the "Naming" section nor the "Macros" section of the Syle Guide say anything about naming macros. Perhaps it should.

      A widely used convention is to use all uppercase, with single underscores for word separators (i.e. all-caps snake-case). (And no leading underscore, as that's reserved.) Often with a per-project prefix, though that's less relevant for HotSpot, since most files are scoped to HotSpot and not included elsewhere.

      However, there are a significant number of lowercase snake-case macros in HotSpot.

      Some people think upper-case macros are very noisy and attention grabbing in a way that decreases readability. Even if most macros are all-caps, for macros that are very commonly used, these folks think allowing them to be lower-case is better. Some examples include assert, guarantee, log_debug/info/&etc.

      Potential for name clashes is the issue. Since HotSpot currently has relatively few external dependencies, it can (mostly) get away with being relaxed about macro naming. If we start making more use of the C++ Standard Library (for example), the possibility of name clashes increases.

            Unassigned Unassigned
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: