-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible functions redesign to use pass-by-reference #283
Comments
Complete redesign implemented in As mentioned, this is a very breaking change, still considering if this is the best approach... Some of my thoughts about it: PROS
CONS
More feedback is welcome! |
I think it is not a bad idea! #define RAYGUI_OUTPUT_VARIABLE And using it as int GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 RAYGUI_OUTPUT_VARIABLE *scroll, Rectangle RAYGUI_OUTPUT_VARIABLE *view); You can use something small like ROUT instead of long as RAYGUI_OUTPUT_VARIABLE |
@anstropleuton The pointer should be enough to note it's an output variable. |
Okay sure! |
I think for this kind of GUI, you are going to have to deal with pointers. Pass by ref is a concept programmers are going to have to deal with in C at some point. I can't see any way around it, other than returning some large structure with new values and that just makes it a pain to use. This method makes the API more consistent, and is inline with other APIs that do the same thing (Dear ImGui). While I understand the desire to minimize pointers, I feel this is a well warranted case for use, and the resulting API will be much easier to use. |
Some
raygui
controls reque one value to be passed and returned after being updated, those function could be redesigned to just pass the variable by reference for internal modification. This will simplify the function and also adds room for a possible return state value, like result of operation or similar (to be analyzed).Affected functions:
Possible review:
Return values are optional. Consistency with other functions should also be considered.
In any case, it is a breaking change, probably to be considered for a
raygui 4.0
release.The text was updated successfully, but these errors were encountered: