Skip to content
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

Any reason for not using "auto" on code base? #49

Closed
afonsolage opened this issue Aug 19, 2019 · 2 comments
Closed

Any reason for not using "auto" on code base? #49

afonsolage opened this issue Aug 19, 2019 · 2 comments

Comments

@afonsolage
Copy link
Contributor

afonsolage commented Aug 19, 2019

Hello folks!

I'm just wondering if there is any reason why not use the auto keyword of C++? It's been there since C++11 and our code base can compile C++17 if I'm not mistaken.

In some parts of code, instead of typing:
const VoxelLightSpreader::OutputBlock &out_block = output.blocks[i];

One would just do:
auto &out_block = output.blocks[i];

I'm asking it before using auto because we should have some kind of "code convention" IHMO.

Thanks!

@Zylann
Copy link
Owner

Zylann commented Aug 19, 2019

So far I've been following similar conventions to those of Godot itself, but since I openly use C++11 features in some places, it's a bit more relaxed (mostly because Godot equivalents are inadapted). I'm not a fan of auto, especially when the type cannot be deduced by solely looking at the line (like your example). So I would suggest to not use it for long term readability, unless it's a horrible one like STL iterators or lambdas with multiple templates in it. In other situations I preferred typedef (Like Mgr in updater and streamer).

@afonsolage
Copy link
Contributor Author

Got it. To be honest, I don't see a problem when using auto, since whenever we are developing C++ we use a IDE, which quick shows us the variable type and, in most cases, you don't really care for the type, since generally you receive it from a function or struct/class members whose the type was already declared someplace else.

When declaring I may agree, since auto i = 0 may sound ambiguous between int and unsigned int.

But anyway, I'll keep not using auto keyword, since most time of my development should be on GDScript, so this shound'nt be a problem.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants