• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] vJass dollar sign in Reforged?

Status
Not open for further replies.
Level 14
Joined
Dec 12, 2012
Messages
1,007
I was looking at the new common.j file (with new Reforged natives) and noticed the following:

JASS:
constant oskeytype OSKEY_BACKSPACE = ConvertOsKeyType($08)
constant oskeytype OSKEY_TAB       = ConvertOsKeyType($09)
constant oskeytype OSKEY_CLEAR     = ConvertOsKeyType($0C)
// and so on

Apparently, it is now possible to declare hex-integers not only with the 0x prefix but also with the $ sign as prefix.

Indeed, the following test script confirms this:


JASS:
library MyLibrary
    private keyword INITS
 
    struct MyStruct extends array
        implement INITS
    endstruct
 
    private module INITS
        private static method onInit takes nothing returns nothing
            local integer i = $1C
            local integer j = 0x1C
        
            call BJDebugMsg(I2S(i)) // Output: 28
            call BJDebugMsg(I2S(j)) // Output: 28
        endmethod
    endmodule
endlibrary


It seems that this is only used for the oskeytype definitions and nowhere else. It is not a vJass extension but works also with the vanilla editor (vJass and Jasshelper disabled).

Since when is this a thing? Was this always possible? Why do we need this redundant syntax?

I am asking because in vJass the $ sign is used for textmacros, which makes this syntax quite problematic (for example for highlighting, as can be also seen in the code snippet above).
 
Last edited:
Level 14
Joined
Dec 12, 2012
Messages
1,007
This has always been possible: JASS Manual: Formal Syntax Definition[/code]

Ok, thanks for the info. I thought this was new because I have never seen it being used anywhere before.

Will add this to my todo list for TESH...

Although I still think the similarity to vJass textmacros is quite unfortunate and potentially confusing. Especially, because hex numbers can start with (or consist entirely of) letters. So $AB could be the hex integer 0xAB or an incomplete textmacro statement (refering to the textmacro argument AB). However, $AG for example could not be a hex integer (invalid letter G) so it could only be an incomplete textmacro statement. This means that $AB and $AG would have to be highlighted differently, if done correctly.
 
Last edited:
Status
Not open for further replies.
Top