Skip to content

[WIP] remove use of useless initializers#5508

Closed
ghost wants to merge 2 commits intomasterfrom
unknown repository
Closed

[WIP] remove use of useless initializers#5508
ghost wants to merge 2 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Jun 23, 2017

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @bbasile! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some things that can help to speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

@dlang-bot dlang-bot added the Review:WIP Work In Progress - not ready for review or pulling label Jun 23, 2017
@quickfur
Copy link
Member

Please don't do this. Explicitly initializing declarations may be "useless" from the compiler's POV, but they are important for readers of the code to understand intent. We should not blindlty remove these documentations of intent just for questionable "savings" of not generating extra AST nodes. I object to this change.

@ghost
Copy link
Author

ghost commented Jun 23, 2017

@quickfur, i understand and i have no special interest into seeing the PR merged. The fact is that i used phobos to improve a d-scanner plugin and now I'm happy to see that it covers 99.7 % of the cases and only errors on.. well 0.3...

That being said, there are inconsistencies in the way people init or not. For example:

     size_t consumed;
-    size_t element = 0;
+    size_t element;

consumed was not while just beyond, element is. Also people should know the language. There's no reason to init just in case of. The compiler will not randomly fail to initialize a variable just where you fear that it happens.

@CyberShadow
Copy link
Member

#5497 (comment)

Thanks for the effort, but I'm fairly sure this is not a change we want.

@quickfur
Copy link
Member

@bbasile Writing an initializer to a default value is not "in case the compiler will randomly fail to initialize it". It is a documentation of intent; it's saying "I am explicitly setting this variable to this value, so pay attention, code reader, because this is important". Declaring a variable without an initializer is saying "x is a variable, it's not important what its initial value is". Nobody writing D code is "afraid" that the compiler won't initialize the value properly; this is D, not C, after all. It's about conveying intent to whoever reads the code.

@quickfur
Copy link
Member

I was not trying to be polite. If you don't care about it, then so be it.

@dlang dlang deleted a comment Jun 25, 2017
@ghost ghost deleted the useless-init branch September 13, 2017 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:WIP Work In Progress - not ready for review or pulling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants