You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there any plans to add macros such as #define, #if, #elif and #endif or some other alternative to allow conditional compilation?
Also is this project still continued since there weren't any updates lately?
The text was updated successfully, but these errors were encountered:
It is a feature that I'd like to add to Gravity, but I don't want to increase the complexity of the code.
For example, the C preprocessor is bigger than the C itself (as codebase), so I need to carefully balance what to do about macro support.
ScriptExec
changed the title
C like conditional compilation
C like conditional compilation and suggested features
Apr 6, 2023
I agree that keeping it simple is the way to go and yeah fully recreating C like macros would be overkill. I was thinking that there should be #define IDENTIFIER value macro like in C and for conditional compilation #ifdef, #ifndef, #if, #else and #endif but I would allow #if to only receive an identifier that is set to either true or false fe.
//I wouldn't allow this (simplified platform macros)
#defineIS_COMPATIBLE OS_WINDOWS && OS_64BIT
//I would only allow this
#defineIS_COMPATIBLE1//or 0, true and false keywords should also work//Setting macro values should also be possible via gravity vm's functions
#if IS_COMPATIBLE
//...
#else//...
#endif//Should other operations be allowed? like:
#if COMPILER_VERSION < 1000
#if COMPILER_VERSION != 1000
//etc
Personally I would also add #warning "message" and #error "message" (they wouldn't be too hard to implement) which would also benefit from the above macros.
Another nice thing that the language could have might be attributes like in C#.
//C# version[Serializable]publicclassSampleClass{// Objects of this type can be serialized.}
//Example Gravity version
@serializableclassSampleClass{
//...
}
Also is it possible to save bytecode and then run it via some function or does the API only allow loading the source?
Are there any plans to add macros such as #define, #if, #elif and #endif or some other alternative to allow conditional compilation?
Also is this project still continued since there weren't any updates lately?
The text was updated successfully, but these errors were encountered: