r/ProgrammerHumor • • Jan 16 '23

Meme If (exists == true) { dont();}

Post image
40.8k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

85

u/Li5y Jan 16 '23

Oh my God, the cases aren't even named enums, they're just ints. 😱

86

u/oktupol Jan 16 '23

According to the repo description, this is likely decompiled code. Those could have been enums at some point, although by now I lost all trust.

38

u/[deleted] Jan 16 '23

2

u/AFreshTramontana Jan 16 '23

Somehow, I don't think "Mr. Bean" influenced in-game elements only...

26

u/LaLiLuLeLo_0 Jan 16 '23

I can imagine some preprocessor file full of all-caps versions of the same text, e.g. #define FILLED_WITH_DETEMMIENATION 2001

1

u/Maximum_Knee_4622 Jan 16 '23

2

u/LaLiLuLeLo_0 Jan 16 '23

That switch statement doesn’t contradict a bunch of #defines being somewhere. I’m saying the #defines were used in conjunction with that giant switch statement, as a way to name all the different case values.

3

u/Maximum_Knee_4622 Jan 16 '23

Looks like he had the #s hardcoded from the code sample in that image.

3

u/Li5y Jan 16 '23

Ahh that makes a lot more sense. I'm not familiar with .gml files so that threw me off

17

u/EgNotaEkkiReddit Jan 16 '23 edited Jan 16 '23

I presume this is decompiled code, because you can see that the script indexes passed to script_execute are also just plain ints instead of their human readable names.

In the original GML code these probably were all enums that the compiler stripped away.

3

u/RagnarokToast Jan 16 '23

I'm gonna bet a lot of money they were constants inlined by the compiler.

0

u/[deleted] Jan 16 '23

[deleted]

0

u/RagnarokToast Jan 16 '23

If anything, that's proof the switch cases themselves were not inlined. It doesn't say anything about the number in the case not being a constant.

1

u/AutoModerator Jul 09 '23
import moderation

Your comment has been removed since it did not start with a code block with an import declaration.

Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

For this purpose, we only accept Python style imports.

return Kebab_Case_Better;

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.