Why does JassHelper alter the number of underscores when saving the map?

Level 28
Joined
Feb 2, 2006
Messages
1,629
Hi,
I am just wondering whenever I save my map generated JASS code lines from vJass with prefixes (library names) and underscores change the number of underscores:

Code:
-hashtable Attributes___h= InitHashtable()
-integer array Attributes___attributes
-integer Attributes___attributesCounter= 0
+hashtable Attributes__h= InitHashtable()
+integer array Attributes__attributes
+integer Attributes__attributesCounter= 0

It changes the three underscores ___ into two underscores __.
For some libraries it happens the other way around:

Code:
-integer CTL__tgc= 0
-integer array CTL__tgr
+integer CTL___tgc= 0
+integer array CTL___tgr

Why is this happening and could I disabled it?

It is a bit annoying when using Git/diffs and seeing so many changes although nothing really changed in vJass.
 
It's used for private members to enforce encapsulation. They wanted to randomize it so people couldn't bypass encapsulation by manually adding the prefix themselves (since ultimately, vJASS gets compiled into regular JASS that you can interact with). From the manual:

JassHelper Manual said:
The way private work is actually by automatically prefixing scopename(random digit)__ to the identifier names of the private members. The random digit is a way to let it be truly private so people can not even use them by adding the preffix themselves. A double _ is used because we decided that it is the way to recognize preprocessor-generated variables/functions, so you should avoid to use double __ in your human-declarated identifier names. Being able to recognize preprocessor-generated identifiers is useful when reading the output file (for example when PJass returns syntax errors).

Sadly, that is definitely quite annoying for Git. I recommend creating a pre-commit git hook that replaces any instances of three underscores with two.
 
Top