Skip to content

Commit 7928140

Browse files
[SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary
1 parent 0ff3239 commit 7928140

File tree

1,137 files changed

+8796
-8672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,137 files changed

+8796
-8672
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ Note: This is in reverse chronological order, so newer entries are added to the
33
Swift 3.0
44
-------
55

6+
* [SE-0046] (https://github.com/apple/swift-evolution/blob/master/proposals/0046-first-label.md) Function parameters now have consistent labelling across all function parameters. With this update the first parameter declarations will now match the existing behavior of the second and later parameters. This change makes the language simpler.
7+
8+
Functions that were written and called as follows
9+
```swift
10+
func foo(x: Int, y: Int) {
11+
}
12+
foo(1, y: 2)
13+
14+
func bar(a a: Int, b: Int) {
15+
}
16+
bar(a: 3, b: 4)
17+
```
18+
will now be written as (to achieve the same behavior):
19+
```swift
20+
func foo(_ x: Int, y: Int) {}
21+
foo(1, y: 2)
22+
func bar(a: Int, b: Int) {}
23+
bar(a: 3, b: 4)
24+
```
25+
626
* [SE-0037](https://github.com/apple/swift-evolution/blob/master/proposals/0037-clarify-comments-and-operators.md)
727
Comments are now treated as whitespace when determining whether an operator is
828
prefix, postfix, or binary. For example, these now work:

benchmark/single-source/Ackermann.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
// for performance measuring.
1515
import TestsUtils
1616

17-
func ackermann(M : Int, _ N : Int) -> Int {
17+
func ackermann(_ M: Int, _ N : Int) -> Int {
1818
if (M == 0) { return N + 1 }
1919
if (N == 0) { return ackermann(M - 1, 1) }
2020
return ackermann(M - 1, ackermann(M, N - 1))
2121
}
2222

2323
@inline(never)
24-
func Ackermann(M : Int, _ N : Int) -> Int {
24+
func Ackermann(_ M: Int, _ N : Int) -> Int {
2525
// This if prevents optimizer from computing return value of Ackermann(3,9)
2626
// at compile time.
2727
if False() { return 0 }
@@ -33,7 +33,7 @@ func Ackermann(M : Int, _ N : Int) -> Int {
3333
let ref_result = [5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069];
3434

3535
@inline(never)
36-
public func run_Ackermann(N: Int) {
36+
public func run_Ackermann(_ N: Int) {
3737
let (m, n) = (3, 9)
3838
var result = 0
3939
for _ in 1...N {

benchmark/single-source/AngryPhonebook.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var words = [
3131
"Bobby", "Dylan", "Johnny", "Phillip", "Craig"]
3232

3333
@inline(never)
34-
public func run_AngryPhonebook(N: Int) {
34+
public func run_AngryPhonebook(_ N: Int) {
3535
// Permute the names.
3636
for _ in 1...N {
3737
for firstname in words {

benchmark/single-source/Array2D.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@inline(never)
14-
public func run_Array2D(N: Int) {
14+
public func run_Array2D(_ N: Int) {
1515
var A: [[Int]] = []
1616
for _ in 0 ..< 1024 {
1717
var B: [Int] = []

benchmark/single-source/ArrayAppend.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import TestsUtils
1616

1717
@inline(never)
18-
public func run_ArrayAppend(N: Int) {
18+
public func run_ArrayAppend(_ N: Int) {
1919
for _ in 0..<N {
2020
for _ in 0..<10 {
2121
var nums = [Int]()
@@ -27,7 +27,7 @@ public func run_ArrayAppend(N: Int) {
2727
}
2828

2929
@inline(never)
30-
public func run_ArrayAppendReserved(N: Int) {
30+
public func run_ArrayAppendReserved(_ N: Int) {
3131
for _ in 0..<N {
3232
for _ in 0..<10 {
3333
var nums = [Int]()

benchmark/single-source/ArrayInClass.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ArrayContainer {
1717
arr = [Int] (repeating: 0, count: 100_000)
1818
}
1919

20-
func runLoop(N: Int) {
20+
func runLoop(_ N: Int) {
2121
for _ in 0 ..< N {
2222
for i in 0 ..< arr.count {
2323
arr[i] = arr[i] + 1
@@ -32,7 +32,7 @@ func getArrayContainer() -> ArrayContainer {
3232
}
3333

3434
@inline(never)
35-
public func run_ArrayInClass(N: Int) {
35+
public func run_ArrayInClass(_ N: Int) {
3636
let a = getArrayContainer()
3737
a.runLoop(N)
3838
}

benchmark/single-source/ArrayLiteral.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func makeArray() -> [Int] {
2121
}
2222

2323
@inline(never)
24-
public func run_ArrayLiteral(N: Int) {
24+
public func run_ArrayLiteral(_ N: Int) {
2525
for _ in 1...10000*N {
2626
makeArray()
2727
}
@@ -34,7 +34,7 @@ func addLiteralArray() -> Int {
3434
}
3535

3636
@inline(never)
37-
public func run_ArrayValueProp(N: Int) {
37+
public func run_ArrayValueProp(_ N: Int) {
3838
var res = 123
3939
for _ in 1...10000*N {
4040
res += addLiteralArray()
@@ -75,7 +75,7 @@ func addLiteralArray4() -> Int {
7575
}
7676

7777
@inline(never)
78-
public func run_ArrayValueProp2(N: Int) {
78+
public func run_ArrayValueProp2(_ N: Int) {
7979
var res = 123
8080
for _ in 1...10000*N {
8181
res += addLiteralArray2()
@@ -85,7 +85,7 @@ public func run_ArrayValueProp2(N: Int) {
8585
}
8686

8787
@inline(never)
88-
public func run_ArrayValueProp3(N: Int) {
88+
public func run_ArrayValueProp3(_ N: Int) {
8989
var res = 123
9090
for _ in 1...10000*N {
9191
res += addLiteralArray3()
@@ -95,7 +95,7 @@ public func run_ArrayValueProp3(N: Int) {
9595
}
9696

9797
@inline(never)
98-
public func run_ArrayValueProp4(N: Int) {
98+
public func run_ArrayValueProp4(_ N: Int) {
9999
var res = 123
100100
for _ in 1...10000*N {
101101
res += addLiteralArray4()

benchmark/single-source/ArrayOfGenericPOD.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func genStructArray() {
5858
}
5959

6060
@inline(never)
61-
public func run_ArrayOfGenericPOD(N: Int) {
61+
public func run_ArrayOfGenericPOD(_ N: Int) {
6262
for _ in 0...N {
6363
genEnumArray()
6464
genIOUArray()

benchmark/single-source/ArrayOfGenericRef.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func genRefStructArray() {
8686
}
8787

8888
@inline(never)
89-
public func run_ArrayOfGenericRef(N: Int) {
89+
public func run_ArrayOfGenericRef(_ N: Int) {
9090
for _ in 0...N {
9191
genPODRefArray()
9292
genCommonRefArray()

benchmark/single-source/ArrayOfPOD.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func genStructArray() {
5353
}
5454

5555
@inline(never)
56-
public func run_ArrayOfPOD(N: Int) {
56+
public func run_ArrayOfPOD(_ N: Int) {
5757
for _ in 0...N {
5858
genIntArray()
5959
genEnumArray()

0 commit comments

Comments
 (0)