-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Remove DEFVAL #46903
Remove DEFVAL #46903
Conversation
I'm not able to approve / review every single line of the pr, but I love the idea. |
I just used regex, so as long as it compiles it should be fine. |
Isn't |
I just checked and it seems like the defaults are still properly documented. |
Looks like it's a simple macro define which does nothing (at least in 3.2): // class_db.h
#define DEFVAL(m_defval) (m_defval) So at most this has readability purpose. But considering that a lot of Godot devs are already familiar with the binding usage, this seems redundant, so I think it makes sense to remove it. I'm for reducing verbosity since binding methods oftentimes take a lot of space wasted beyond 120 chars line. |
I'm against this, because it makes the bindings much less clear, especially when you have a lot of variables and a lot of bindings. |
I don't have a strong opinion, but I also tend to like having the explicit I also think that That being said I didn't know until yesterday that |
@AndreaCatania I'm kind of surprised that you think this way because you've previously expressed that you're for reducing verbosity in Godot as a whole, see your own gist in https://gist.github.com/AndreaCatania/fdf9bd9942779ac9ec0c58be26393fd4. 😮 Unless I misunderstand something. One could say that using TL;DR: don't act like reduz. 😛 |
Well, it's nice to know about this, developers can now choose to omit I agree that it's more explicit, but that sort of explicitness made refactoring a hell in the past for me. It makes it more difficult to re-arrange default value, and it's easy to make a mistake since Also, a more explicit way to define parameters would be to wrap them in some kind of ClassDB::bind_method(D_METHOD("method", "arg0", ARG("arg1", 37), ARG("arg2", "Hello")), &Class::_method); As you see, this can achieve explicitness and clarity (yes, explicitness does not necessarily mean clarity). |
@Xrayez I'm all for improving the syntax and make it less verbose, but I've the feeling that just doing this change is not enough. Rather, it's going to make things look more complex, IMO. Taking this as reference: https://github.com/godotengine/godot/blob/master/core/io/image.cpp#L3088 ClassDB::bind_method(D_METHOD("resize_to_po2", "square", "interpolation"), &Image::resize_to_po2, DEFVAL(false), DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("detect_used_channels", "source"), &Image::detect_used_channels, DEFVAL(COMPRESS_SOURCE_GENERIC));
ClassDB::bind_method(D_METHOD("compress", "mode", "source", "lossy_quality"), &Image::compress, DEFVAL(COMPRESS_SOURCE_GENERIC), DEFVAL(0.7));
ClassDB::bind_method(D_METHOD("compress_from_channels", "mode", "channels", "lossy_quality"), &Image::compress_from_channels, DEFVAL(0.7)); ClassDB::bind_method(D_METHOD("resize_to_po2", "square", "interpolation"), &Image::resize_to_po2, false, INTERPOLATE_BILINEAR);
ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, INTERPOLATE_BILINEAR);
ClassDB::bind_method(D_METHOD("detect_used_channels", "source"), &Image::detect_used_channels, COMPRESS_SOURCE_GENERIC);
ClassDB::bind_method(D_METHOD("compress", "mode", "source", "lossy_quality"), &Image::compress, COMPRESS_SOURCE_GENERIC, 0.7);
ClassDB::bind_method(D_METHOD("compress_from_channels", "mode", "channels", "lossy_quality"), &Image::compress_from_channels, 0.7); I feel like that the last parameters may be miss understood for ""additional config"" on the binding, while |
Still not sure which way to go between keeping Here's a couple pathological examples where I think the cosmetic
Without
(Put them as inline code on purpose as code blocks add a scrollbar which defeats the aim of this demonstration :)) Since default values apply to the rightmost arguments, searching For |
The arguments are cosmetic DEFVAL helps make things clearer and it is the current status. So the status quo has an advantage over the alternative which making things unclear and create a lot of noise in commits. |
How about making |
|
As others have expressed, I also prefer the way things are right now for better readability. Given there is no consensus on this I will be closing the PR. |
It doesn't do anything and gives false impression that it's needed.