-Are enums 32bit Uint or 32 bit signed Int? I can see an issue where it says ints can’t have negative literal.. (https://github.com/blitz-research/monkey2/issues/138). It looks like in C++ it can have negative members, wich can be a problem for importing external enums.
I still wonder if enums are primitive types (strings are so may be..) and if enums (will) have uint or int members. So I can make a correct description in the docs. (Looking at enum.monkey2 & values.monkey2 did not help me)
An Enum will compile to an opaque enum class in the c++ source which uses a signed int for its base. For some reason, M2’s Enum will not accept negative values. I think this might be a parser bug as I can do this
Monkey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#Import"<std>"
Using std..
EnumDirection
up=0-10,down,left,right,
end
FunctionMain()
Localdirection:=Direction.down
Ifdirection=Direction.up
Print"You are moving up"
Else
Print"You are not moving up"
Endif
End
And it works as expected. (much easier to understand than the $FFFFFFFF hack I posted earlier)