09.06.2018, 12:17
(
Последний раз редактировалось Y_Less; 09.06.2018 в 12:50.
)
The wiki doesn't use a colon. YSI doesn't use a colon. pawn-lang.pdf doesn't use a colon. I've literally never seen any code that uses a colon, and I'm amazed it even compiles with a colon.
Frankly, I'm not even sure why you're asking. You've found that using a colon means that the enum can't be used in many situations, and not using a colon does the same thing, so why even pursue the clearly inferior route?
I did just do some experimentation, I think this is what's happening:
That is an enum called "E_THING" that increases every value 3-fold.
That is an anonymous enum, which means that you can't do things like `new arr[E_THING]`, because that enum doesn't exist with that name. Instead, it is the same as doing:
But with a tag override on the increment. Which is interesting, because that means that all the enum elements still have the TAG `E_THING`, but the enum called `E_THING` doesn't exist.
Edit: Actually, the tagging without being usable as array sizes has use.
Edit 2: After some discussion on discord, this also works:
Which is a nameless (sizeless) enum with a tag of `e_TAG`.
However, totally unrelated to this point. Your original question was about using this in arrays. If you do:
Then the total size (the value of `E_NUM`) will be 8, not 3, because it is still subject to the same shifting rules.
Frankly, I'm not even sure why you're asking. You've found that using a colon means that the enum can't be used in many situations, and not using a colon does the same thing, so why even pursue the clearly inferior route?
I did just do some experimentation, I think this is what's happening:
PHP код:
enum E_THING (*= 3)
{
E_A
}
PHP код:
enum E_THING:(+= 77)
{
E_A
}
PHP код:
enum (+= 77)
{
E_A
}
Edit: Actually, the tagging without being usable as array sizes has use.
Edit 2: After some discussion on discord, this also works:
PHP код:
enum e_TAG:
{
}
However, totally unrelated to this point. Your original question was about using this in arrays. If you do:
PHP код:
enum E_NUM (<<= 1)
{
E_NUM_0 = 1,
E_NUM_1,
E_NUM_2,
}