/////////////////////
// ENABLE THE BUG ///
/////////////////////
#define BUGMEBABY TRUE
#if BUGMEBABY
// This needs to be defined above to be accessed within the preprocessor at the moment.
#define TRUE 1
#define FALSE 0
#endif
// [Edit] TRUE & FALSE seem to be var/const instead of #define, wouldn't it make sense to use #define TRUE 1 & #define FALSE 0 in stddef.dm?
ID:2371109
May 24 2018, 10:02 am (Edited on May 24 2018, 10:18 am)
|
|||||||
Resolved
| |||||||
New stddefs:
// directions |
Seems like a back-compat hazard. Other than MAYBE TRUE and FALSE, what else could you possibly be wanting to do preprocessor logic on?
|
Seems like a back-compat hazard. After the code has been compiled, it shouldn't really make a difference. Old DME files should probably still keep those global constants around, but again, version-locking can get rid of them. The only issue is savefile compatability, but that can also be version-checked where savefiles with the old version prefix will just be aware of the old constants mapped to the new literals. For current code, it won't make a whit of difference. Most of these constants have been the same for 20 years. Keeping them mutable because they could change runs counter to the fact that they have always been solid, and really haven't changed. Hell, even a big ol' chunk of old code doesn't compile properly today. Compatability has always been something that's taken up way too much headspace for really no reason. |
I feel your point on the compatability, but if these constants haven't changed why would you need to gate preprocessor logic on them?
|
Global const var lookup may be one of the fastest var lookup types, its still a var lookup, its still overhead that compiled in numbers don't have, and the seemingly random way they switch between being consts and defines has always made it hard to know what values can be used where.
Switching to defines would bring a performance boost as well as a consistency boost. |
In response to SpaceManiac
|
|
SpaceManiac wrote:
I feel your point on the compatability, but if these constants haven't changed why would you need to gate preprocessor logic on them? var/const Because using NORTHEAST|UP in a preprocessor is more readable than 21, in that it shows what 21 actually corresponds to, and if the readable solution is less performant at runtime than the unreadable one, it had better be for a good reason. You just agreed that it isn't. |
When would you need to use NORTHEAST|UP in an #if though? Note that it works fine in a #define because it will be expanded and resolved later.
The performance concern makes sense. If making these defines makes things faster I approve. |
When would you need to use NORTHEAST|UP in an #if though? Note that it works fine in a #define because it will be expanded and resolved later. That wasn't what I was getting at. I was pointing out that the readable solution being less performant was stupid unless there was good reason for it. There isn't. |
Is either state of being more or less readable? If it's less performant for no good reason it should be changed but "I want to use TRUE in #if" alone does not justify the change IMO.
|
In response to SpaceManiac
|
|
SpaceManiac wrote:
"I want to use TRUE in #if" alone does not justify the change IMO. I'm here for the performance, and to me it's common sense that TRUE/FALSE should be defined, not var/const. |
There's a lot of logic to this. The main thing I need to do is look at how old savefiles behave with these constants to see if I need to make any changes for version awareness.
|
Lummox JR resolved issue with message:
The const vars in stddef.dm have been changed to #define statements. |
When I looked into this I tried saving to see if the const vars showed up in the file, and they did not.
I am however somewhat second-guessing myself and asking if maybe I should leave the const vars in, but have them precede the various defines so the defines take precedence anywhere the vars are used. The const vars would have basically no impact on any games but would allow any sneaky back-compat issues to be resolved. |
stddef.dm