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

[stdlib] Use type inference for Bool vars #245

Closed
wants to merge 1 commit into from

Conversation

jawwad
Copy link
Contributor

@jawwad jawwad commented Dec 5, 2015

This commit makes the declarations of boolean variables more concise by using type inference

@CodaFi
Copy link
Contributor

CodaFi commented Dec 5, 2015

It may be concise, but I always appreciate when type annotations are kept around, even in simple cases like this.

@liambutler-lawrence
Copy link

+1 on this. In my opinion, type annotations can be useful when the type is unclear from a quick glance (for example, when assigning the result of a long function chain). In this case, however, we're clearly assigning a Boolean literal (either "true" or "false") to each variable. Explicitly writing “: Bool” only makes the declaration longer and less instantly readable.

@jawwad
Copy link
Contributor Author

jawwad commented Dec 7, 2015

While I do prefer always using type inference, I can appreciate how others including @CodaFi would prefer that they be kept around so this change may be more subjective than I thought. And perhaps a bit more in the case of instance variables where other variables without initial default values have types specified. Curious to hear what others have to say on this, and if Apple has any kind of recommendation on minor style concerns like this.

@gribozavr
Copy link
Contributor

@jawwad Some of the library code will be fragile, and having explicit type annotations will help to not accidentally break ABI. We prefer to postpone this discussion until resilience is implemented and applied to the library.

@gribozavr gribozavr closed this Dec 22, 2015
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
Windows cleanups

Signed-off-by: Daniel A. Steffen <[email protected]>
dabelknap added a commit to dabelknap/swift that referenced this pull request Jun 5, 2019
Fix a bug where code lines are lost for OrderedImports rule
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
Add environment variable for projects to detect it's running part of Swift Source Compat Suite
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

Successfully merging this pull request may close these issues.

4 participants