Skip to content

Removed the ++ and -- operators #281

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

Merged
merged 25 commits into from
Dec 26, 2015
Merged

Removed the ++ and -- operators #281

merged 25 commits into from
Dec 26, 2015

Conversation

divadretlaw
Copy link
Contributor

Removed the ++ and -- operators as they will no longer work with
upcoming changes

https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md

Removed the ++ and -- operators as they will no longer work with
upcoming changes
Removed some C-style loops and postincrements
++i
i = i.successor()
i = i.successor()
i = i.successor()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something, but why not use i += 3? Seems more succinct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i += 3 does not work with an Index
i = i.advancedBy(3) could be used but maybe whoever originally wrote that code wanted to use 3 statements for whatever reason.

@azdavis
Copy link

azdavis commented Dec 6, 2015

Ah, I was wondering why you weren't using arithmetic operators; I didn't realize Index was its own class. Anyway, 👍

@@ -34,7 +34,8 @@ public struct _stdlib_ShardedAtomicCounter {
let hardwareConcurrency = _stdlib_getHardwareConcurrency()
let count = max(8, hardwareConcurrency * hardwareConcurrency)
let shards = UnsafeMutablePointer<Int>.alloc(count)
for var i = 0; i != count; i++ {
for i in 0...count {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 0..<count.

@gribozavr
Copy link
Contributor

Thank you! There are a lot more in the tests.

Simplfied successor for UnsafePointer and removed unnecessary comments
Removed some post-, preincrement/decrements from test
++i
++i
++i
i = i.advancedBy(3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the test code the exact equivalent. The test name says it is testing the successor() function.

@gribozavr
Copy link
Contributor

Please remove unrelated whitespace changes from the patch.

}
// Initialize the hole left by sliding the tail forward
for j in oldTailIndex..<newTailIndex {
(elements + j).initialize(newValues[i++])
(elements + j).initialize(newValues[i])
i = i.successor()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i._successorInPlace()

@gribozavr
Copy link
Contributor

Please compile the code and run tests before submitting -- utils/build-script -RT.

@katzenbaer
Copy link

Would it be better if this change was merged in at the same time as the removal of the post/pre operators?

@gribozavr
Copy link
Contributor

No, for two reasons: incremental development, and shaking out possible performance issues.

@katzenbaer
Copy link

@gribozavr Just to clarify, is that reasoning for accepted proposals? I understand this isn't the case here, but I would imagine it to be counterproductive to merge in changes when the decision has yet to be finalized.

@gribozavr
Copy link
Contributor

@katzenbaer Yes, just for accepted proposals.

@gribozavr
Copy link
Contributor

@divadretlaw I'm sorry for the delays, would you mind rebasing the PR and resolving the conflicts?

@lattner
Copy link
Contributor

lattner commented Dec 22, 2015

Oh, I'm sorry, I didn't realize that there was an outstanding patch to help with this.

# Conflicts:
#	stdlib/private/SwiftPrivate/ShardedAtomicCounter.swift
#	stdlib/public/core/ArrayCast.swift
#	stdlib/public/core/Collection.swift
#	stdlib/public/core/ContiguousArrayBuffer.swift
#	stdlib/public/core/StringBuffer.swift
#	stdlib/public/core/StringUnicodeScalarView.swift
#	test/1_stdlib/Builtins.swift
#	test/1_stdlib/Collection.swift
#	test/1_stdlib/ErrorType.swift
#	test/1_stdlib/ErrorTypeBridging.swift
#	test/1_stdlib/ExistentialCollection.swift
#	test/1_stdlib/Float.swift
#	test/1_stdlib/Map.swift
#	test/1_stdlib/Mirror.swift
#	test/1_stdlib/Optional.swift
#	test/DebugInfo/arg-debug_value.swift
#	test/DebugInfo/closure.swift
#	test/DebugInfo/for.swift
#	test/DebugInfo/return.swift
#	test/Interpreter/availability_weak_linking.swift
#	test/Interpreter/break_continue.swift
#	test/SILGen/sil_locations.swift
#	test/SILGen/statements.swift
#	test/SILGen/unreachable_code.swift
#	test/SILPasses/definite_init_diagnostics.swift
#	test/SILPasses/return.swift
#	test/SILPasses/switch.swift
#	test/SILPasses/unreachable_code.swift
lattner added a commit that referenced this pull request Dec 26, 2015
Removed the ++ and -- operators
@lattner lattner merged commit fc9887f into swiftlang:master Dec 26, 2015
@gribozavr
Copy link
Contributor

Sorry, but this change causes test failures:

Failing Tests (3):
    Swift :: SILGen/coverage_while.swift
    Swift :: SILGen/sil_locations.swift
    Swift :: Sema/immutability.swift

I'll revert.

@gribozavr
Copy link
Contributor

@divadretlaw Could you take a look at the test failures, fix and resubmit a new PR?

slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
the buffer size ioctls on linux return EINVAL when it's not supported
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
the buffer size ioctls on linux return EINVAL when it's not supported

Signed-off-by: Daniel A. Steffen <[email protected]>
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.

6 participants