• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED]Does DCE exists in GMS 1.4?

Paskaler

Member
I've read somewhere on the forums that constant expressions will get evaluated at compile time, but I can't find the post and I'm unsure whether or not this is a GMS 2 only thing. I'd also like to add that I'm using the Early Access version of GMS in case it only exists there.

So, I have a macro defined DEBUG as true. If I change it to false, what would happen to code like this:
Code:
if DEBUG {
   show_debug_message( "hello" );
}
Will the compiler simply remove the entire thing, as there is no chance of ever running that code. I'm asking this since, up to now, I've had a weird obsession of adding debug code only when something breaks and removing it immediately after I fix the part that wasn't working and this means that there are times when I remove and the re-add the same debug code and this can get pretty annoying. So, basically, if this gets removed by the compiler, that means that I don't have to fix my silly OCD :D
 

jo-thijs

Member
I've read somewhere on the forums that constant expressions will get evaluated at compile time, but I can't find the post and I'm unsure whether or not this is a GMS 2 only thing. I'd also like to add that I'm using the Early Access version of GMS in case it only exists there.

So, I have a macro defined DEBUG as true. If I change it to false, what would happen to code like this:
Code:
if DEBUG {
   show_debug_message( "hello" );
}
Will the compiler simply remove the entire thing, as there is no chance of ever running that code. I'm asking this since, up to now, I've had a weird obsession of adding debug code only when something breaks and removing it immediately after I fix the part that wasn't working and this means that there are times when I remove and the re-add the same debug code and this can get pretty annoying. So, basically, if this gets removed by the compiler, that means that I don't have to fix my silly OCD :D
You can easily test this yourself.

Use this code to compare MACRO speed:
Code:
var t = current_time;

repeat 100000000 {
    if DEBUG {
        show_message("hi");
    }
}

show_message(current_time - t);
This code to compare commented speed:
Code:
var t = current_time;

repeat 100000000 {
//    if DEBUG {
//        show_message("hi");
//    }
}

show_message(current_time - t);
And this code to compare vriable speed:
Code:
var t = current_time;
var debug = false;

repeat 100000000 {
    if debug {
        show_message("hi");
    }
}

show_message(current_time - t);
The results when I tested this on the windows target for GM:S 1.4 are:
Code:
MACRO (Windows):
4827
4811
4779
4805

COMMENTED (Windows):
4825
4785
4786
4814

VARIABLE (Windows):
8067
8149
8120
8005
I conclude that if-statements with a boolean constant as condition are indeed removed entirely in the end result of the GM:S 1.4 compilation for the windows target.

PS: Was it this comment you read?
https://forum.yoyogames.com/index.p...-and-i-have-some-questions.49622/#post-304433
 
Top