Skip to content

Commit 8426e5d

Browse files
committed
Merge pull request #1 from apple/master
merge mainline
2 parents 1c442b7 + ffcf835 commit 8426e5d

39 files changed

+4473
-703
lines changed

0000-template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ developers create better Swift code.
2626

2727
Describe your solution to the problem. Provide examples and describe
2828
how they work. Show how your solution is better than current
29-
workarounds: is a cleaner, safer, or more efficient?
29+
workarounds: is it cleaner, safer, or more efficient?
3030

3131
## Detailed design
3232

@@ -39,7 +39,7 @@ reasonably implement the feature.
3939

4040
## Impact on existing code
4141

42-
Describe the impact this change will have on existing code. Will some
42+
Describe the impact that this change will have on existing code. Will some
4343
Swift applications stop compiling due to this change? Will applications still
4444
compile but produce different behavior than they used to? Is it
4545
possible to migrate existing Swift code to use a new feature or API

README.md

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ concretely, this release is focused on several key areas:
4343
* **API design guidelines**: The way in which Swift is used in popular
4444
libraries has almost as much of an effect on the character of Swift
4545
code as the Swift language itself. The [API design
46-
guidelines](https://swift.org/documentation/api-design-guidelines.html) provide guidance for
46+
guidelines](https://swift.org/documentation/api-design-guidelines/) provide guidance for
4747
building great Swift APIs. For Swift 3.0, the Swift standard library
4848
and core libraries are being updated to match these guidelines, and
4949
Swift's Objective-C importer will [automatically map](proposals/0005-objective-c-name-translation.md) from the [Cocoa guidelines for
@@ -76,9 +76,11 @@ sampling of potentially good ideas that are not in scope for Swift
7676
interoperability with C++ is a significant undertaking that is out
7777
of scope for Swift 3.0.
7878

79-
* **Hygienic Macros**: A first-class macro system is something we may consider
80-
in future releases. We don't want the existence of a macro system to be a
81-
workaround that reduces the incentive for making the core language great.
79+
* **Hygienic Macros** and **Compile-Time Evaluation**: A first-class macro
80+
system, or support for compile-time code execution in general, is something
81+
we may consider in future releases. We don't want the existence of a macro
82+
system to be a workaround that reduces the incentive for making the core
83+
language great.
8284

8385
* **Major new library functionality**: The Swift Standard Library is focused on
8486
providing core "language" functionality as well as common data structures. The
@@ -91,14 +93,30 @@ sampling of potentially good ideas that are not in scope for Swift
9193
with the Swift Package Manager. Beyond Swift 3 we may consider standardizing
9294
popular packages or expanding the scope of the project.
9395

96+
### Implemented proposals for Swift 3
97+
98+
* [SE-0005: Better Translation of Objective-C APIs Into Swift](proposals/0005-objective-c-name-translation.md)
99+
* [SE-0006: Apply API Guidelines to the Standard Library](proposals/0006-apply-api-guidelines-to-the-standard-library.md)
100+
* [SE-0019: Swift Testing](proposals/0019-package-manager-testing.md)
101+
* [SE-0031: Adjusting inout Declarations for Type Decoration](proposals/0031-adjusting-inout-declarations.md)
102+
* [SE-0023: API Design Guidelines](proposals/0006-apply-api-guidelines-to-the-standard-library.md)
103+
* [SE-0028: Modernizing Swift's Debugging Identifiers (\__FILE__, etc)](proposals/0028-modernizing-debug-identifiers.md)
104+
* [SE-0034: Disambiguating Line Control Statements from Debugging Identifiers](proposals/0034-disambiguating-line.md)
105+
* [SE-0040: Replacing Equal Signs with Colons For Attribute Arguments](proposals/0040-attributecolons.md)
106+
94107
### Accepted proposals for Swift 3.0
95108

96-
* [Better Translation of Objective-C APIs Into Swift](proposals/0005-objective-c-name-translation.md) (SE-0005)
97-
* [Removing currying `func` declaration syntax](proposals/0002-remove-currying.md) (SE-0002)
98-
* [Removing `var` from Function Parameters](proposals/0003-remove-var-parameters.md)
99-
* [Remove the `++` and `--` operators](proposals/0004-remove-pre-post-inc-decrement.md) (SE-0004)
100-
* [Remove C-style for-loops with conditions and incrementers](proposals/0007-remove-c-style-for-loops.md) (SE-0007)
101-
* [Swift Testing](proposals/0019-package-manager-testing.md) (SE-0019)
109+
* [SE-0002: Removing currying `func` declaration syntax](proposals/0002-remove-currying.md)
110+
* [SE-0003: Removing `var` from Function Parameters](proposals/0003-remove-var-parameters.md)
111+
* [SE-0004: Remove the `++` and `--` operators](proposals/0004-remove-pre-post-inc-decrement.md)
112+
* [SE-0007: Remove C-style for-loops with conditions and incrementers](proposals/0007-remove-c-style-for-loops.md)
113+
* [SE-0029: Remove implicit tuple splat behavior from function applications](proposals/0029-remove-implicit-tuple-splat.md)
114+
* [SE-0033: Import Objective-C Constants as Swift Types](proposals/0033-import-objc-constants.md)
115+
* [SE-0035: Limiting `inout` capture to `@noescape` contexts](proposals/0035-limit-inout-capture.md)
116+
* [SE-0037: Clarify interaction between comments & operators](proposals/0037-clarify-comments-and-operators.md)
117+
* [SE-0038: Package Manager C Language Target Support](proposals/0038-swiftpm-c-language-targets.md)
118+
* [SE-0039: Modernizing Playground Literals](proposals/0039-playgroundliterals.md)
119+
* [SE-0046: Establish consistent label behavior across all parameters including first labels](proposals/0046-first-label.md)
102120

103121
## Development minor version: Swift 2.2
104122

@@ -116,25 +134,35 @@ sooner.
116134

117135
### Implemented proposals for Swift 2.2
118136

119-
* [Allow (most) keywords as argument labels](proposals/0001-keywords-as-argument-labels.md) (SE-0001)
120-
* [Tuple comparison operators](proposals/0015-tuple-comparison-operators.md) (SE-0015)
121-
* [Constraining `AnySequence.init`](proposals/0014-constrained-AnySequence.md) (SE-0014)
122-
* [Replace `typealias` keyword with `associatedtype` for associated type declarations](proposals/0011-replace-typealias-associated.md) (SE-0011)
123-
* [Naming Functions with Argument Labels](proposals/0021-generalized-naming.md) (SE-0021)
137+
* [SE-0001: Allow (most) keywords as argument labels](proposals/0001-keywords-as-argument-labels.md)
138+
* [SE-0015: Tuple comparison operators](proposals/0015-tuple-comparison-operators.md)
139+
* [SE-0014: Constraining `AnySequence.init`](proposals/0014-constrained-AnySequence.md)
140+
* [SE-0011: Replace `typealias` keyword with `associatedtype` for associated type declarations](proposals/0011-replace-typealias-associated.md)
141+
* [SE-0021: Naming Functions with Argument Labels](proposals/0021-generalized-naming.md)
142+
* [SE-0022: Referencing the Objective-C selector of a method](proposals/0022-objc-selectors.md)
124143

125144
### Accepted proposals for Swift 2.2
126-
* [Add a Lazy flatMap for Sequences of Optionals](proposals/0008-lazy-flatmap-for-optionals.md) (SE-0008)
127-
* [Swift Language Version Build Configuration](proposals/0020-if-swift-version.md) (SE-0020)
128-
* [Referencing the Objective-C selector of a method](proposals/0022-objc-selectors.md) (SE-0022)
145+
* [SE-0008: Add a Lazy flatMap for Sequences of Optionals](proposals/0008-lazy-flatmap-for-optionals.md)
146+
* [SE-0020: Swift Language Version Build Configuration](proposals/0020-if-swift-version.md)
129147

130148
# Other Proposals
131149

132150
### Rejected proposals
133-
* [Require self for accessing instance members](proposals/0009-require-self-for-accessing-instance-members.md) (SE-0009)
134-
* [Remove Partial Application of Non-Final Super Methods (Swift 2.2)](proposals/0013-remove-partial-application-super.md) (SE-0013, Jan 9-13)
151+
* [SE-0009: Require self for accessing instance members](proposals/0009-require-self-for-accessing-instance-members.md)
152+
* [SE-0010: Add StaticString.UnicodeScalarView](proposals/0010-add-staticstring-unicodescalarview.md)
153+
* [SE-0013: Remove Partial Application of Non-Final Super Methods (Swift 2.2)](proposals/0013-remove-partial-application-super.md)
154+
* [SE-0024: Optional Value Setter `??=`](proposals/0024-optional-value-setter.md)
155+
* [SE-0027: Expose code unit initializers on String](proposals/0027-string-from-code-units.md)
135156

136157
## Review
137158
[Swift Evolution Review Schedule](https://github.com/apple/swift-evolution/blob/master/schedule.md)
138159

139160
### Returned for Revision
140-
* [Flexible Memberwise Initialization](proposals/0018-flexible-memberwise-initialization.md) (SE-0018)
161+
162+
* [SE-0018: Flexible Memberwise Initialization](proposals/0018-flexible-memberwise-initialization.md)
163+
* [SE-0025: Scoped Access Level](proposals/0025-scoped-access-level.md)
164+
* [SE-0030: Property Behaviors](proposals/0030-property-behavior-decls.md)
165+
166+
### Deferred for Future Discussion
167+
168+
* [SE-0026: Abstract classes and methods](proposals/0026-abstract-classes-and-methods.md)

commonly_proposed.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ Several of the discussions below refer to "C Family" languages. This is intende
2424

2525
* [Rename `guard` to `unless`](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005534.html): It is a common request to ask that `guard` be renamed `unless`. People requesting this change argue that `guard` is simply a logically-inverted `if` statement, and therefore `unless` is a more obvious keyword. However, such requests stem from a fundamental misunderstanding of the functionality provided by `guard`. Unlike `if`, `guard` *enforces* that the code within its curly braces provides an early exit from the codepath. In other words, a `guard` block **must** `return`, `throw`, `break`, `continue` or call a `@noreturn` function such as `fatalError()`. This differs from `if` quite significantly, and therefore the parallels assumed between `guard` and `if` are not valid.
2626

27+
* [Use Garbage Collection instead of ARC](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160208/009403.html): Mark and sweep garbage collection is a well known technique used in many popular and widely used languages (e.g. Java and Javascript) and it has the advantage of automatically collecting reference cycles that ARC requires the programmer to reason about. That said, garbage collection has a [large number of disadvantages](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160208/009422.html) and using it would prevent Swift from successfully targeting a number of systems programming domains. For example, real time systems (video or audio processing), deeply embedded controllers, and most kernels find GC to be generally unsuitable. Further, GC is only efficient when given 3-4x more memory to work with than the process is using at any time, and this tradeoff is not acceptable for Swift.
28+
2729
Here are some other less-commonly proposed changes that have also been rejected:
2830

2931
* [Remove `;` Semicolons](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002421.html): Semicolons within a line are an intentional expressivity feature. Semicolons at the end of the line should be handled by a "linter", not by the compiler.
3032

3133
* [Remove support for `default:` in Switch, and just use `case _:`](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001422.html): `default` is widely used, `case _` is too magical, and default is widely precedented in many C family languages.
3234

3335
* [SE-0009: Require self for accessing instance members ](proposals/0009-require-self-for-accessing-instance-members.md)
36+
37+
* [SE-0024: Optional Value Setter `??=`](proposals/0024-optional-value-setter.md)
38+
39+
* [SE-0027: Expose code unit initializers on String](proposals/0027-string-from-code-units.md)
40+
41+
* [SE-0010: Add StaticString.UnicodeScalarView](proposals/0010-add-staticstring-unicodescalarview.md)

proposals/0005-objective-c-name-translation.md

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
* Proposal: [SE-0005](https://github.com/apple/swift-evolution/blob/master/proposals/0005-objective-c-name-translation.md)
44
* Author(s): [Doug Gregor](https://github.com/DougGregor), [Dave Abrahams](https://github.com/dabrahams)
5-
* Status: **Under Review** (January 22...February 5, 2016)
5+
* Status: **Accepted** ([Rationale](http://thread.gmane.org/gmane.comp.lang.swift.evolution/8590))
66
* Review manager: [Doug Gregor](https://github.com/DougGregor)
77

88
## Reviewer notes
@@ -107,11 +107,11 @@ control over the process.
107107

108108
5. **Prepend "is" to Boolean properties**: [Boolean properties should read as assertions on the receiver](https://swift.org/documentation/api-design-guidelines.html#boolean-assertions), but the Objective-C Coding Guidelines for Cocoa [prohibit the use of "is" on properties](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-BAJGIIJE). Import such properties with "is" prepended.
109109

110-
6. **Strip the "NS" prefix from Foundation APIs**: Foundation is a
111-
fundamental part of the [Swift Core Libraries][core-libraries], and
112-
having the prefixes on these cross-platform APIs feels
113-
anachronistic. Therefore, remove the "NS" prefix from entities defined
114-
in the Foundation module (and other specifically identified modules where it makes sense).
110+
6. **Lowercase values**: The Swift API Design Guidelines have non-type
111+
declarations lowercased. Lowercase non-prefixed values whenever they
112+
are imported, including enumerators (whether they end up in Swift as
113+
enum cases or option sets) and any other properties/functions (e.g., a
114+
property named `URLHandler` will be lowercased to `urlHandler`).
115115

116116
7. **Adopt Comparable to classes that implement** `compare(_:) -> NSComparisonResult`: The objective-c classes that implement compare all have declared a capability of being compared in an ordered manner. `Comparable` formalizes this declaration into an implementable operator by the import process.
117117

@@ -137,21 +137,21 @@ the imported `UIBezierPath` API in Swift 2:
137137

138138
And the same API imported under our current, experimental implementation of this proposal:
139139

140-
class UIBezierPath : Object, Copying, Coding {
141-
convenience init(ovalIn: CGRect)
142-
func moveTo(_: CGPoint)
143-
func addLineTo(_: CGPoint)
144-
func addCurveTo(_: CGPoint, controlPoint1: CGPoint, controlPoint2: CGPoint)
145-
func addQuadCurveTo(_: CGPoint, controlPoint: CGPoint)
146-
func append(_: UIBezierPath)
140+
class UIBezierPath : NSObject, NSCopying, NSCoding {
141+
convenience init(ovalIn rect: CGRect)
142+
func move(to point: CGPoint)
143+
func addLine(to point: CGPoint)
144+
func addCurve(to endPoint: CGPoint, controlPoint1 controlPoint1: CGPoint, controlPoint2 controlPoint2: CGPoint)
145+
func addQuadCurve(to endPoint: CGPoint, controlPoint controlPoint: CGPoint)
146+
func append(_ bezierPath: UIBezierPath)
147147
func reversing() -> UIBezierPath
148-
func apply(_: CGAffineTransform)
148+
func apply(_ transform: CGAffineTransform)
149149
var isEmpty: Bool { get }
150-
func contains(_: CGPoint) -> Bool
151-
func fillWith(_: CGBlendMode, alpha: CGFloat)
152-
func strokeWith(_: CGBlendMode, alpha: CGFloat)
153-
func copy(zone _: Zone = nil) -> AnyObject
154-
func encodeWith(_: Coder)
150+
func contains(_ point: CGPoint) -> Bool
151+
func fill(_ blendMode: CGBlendMode, alpha alpha: CGFloat)
152+
func stroke(_ blendMode: CGBlendMode, alpha alpha: CGFloat)
153+
func copy(with zone: NSZone = nil) -> AnyObject
154+
func encode(with aCoder: NSCoder)
155155
}
156156

157157
In the latter case, a number of words that restated type information
@@ -612,18 +612,18 @@ to become:
612612

613613
#### Add First Argument Labels
614614

615-
When the first parameter of a method is defaulted, **split the first
616-
selector piece if it contains a preposition**, turning everything
615+
If the first selector piece contains a preposition, **split the first
616+
selector piece at the last preposition**, turning everything
617617
starting with the last preposition into a *required* label for the
618-
first argument. If the generated first argument label starts with the
619-
word "with", drop the "with".
618+
first argument.
620619

621-
This heuristic eliminates words that refer only to the first
620+
As well as creating first argument label for a significant number of
621+
APIs, this heuristic eliminates words that refer only to the first
622622
argument from call sites where the argument's default value is
623623
used. For example, instead of:
624624

625625
<pre>
626-
extension NSArray {
626+
extension UIBezierPath {
627627
func enumerateObjects<b>With</b>(_: NSEnumerationOptions <b>= []</b>, using: (AnyObject, UnsafeMutablePointer<ObjCBool>) -> Void)
628628
}
629629

@@ -670,33 +670,6 @@ extension NSBezierPath {
670670
if path.<b>isEmpty</b> { ... }
671671
</pre>
672672

673-
### Stripping the "NS" Prefix
674-
675-
The removal of the "NS" prefix for the Foundation module (or other
676-
specifically identified modules) is a mechanical translation for all
677-
global symbols defined within that module that can be performed in the
678-
Clang importer. Note that this removal can create conflicts with the
679-
standard library. For example, `NSString` and `NSArray` will become
680-
`String` and `Array`, respectively, and Foundation's versions will
681-
shadow the standard library's versions. In cases where the Swift 3
682-
names of standard library entities conflict with prefix-stripped
683-
Foundation entities, we retain the `NS` prefix. These Foundation
684-
entities are: `NSArray`, `NSDictionary`, `NSInteger`, `NSRange`,
685-
`NSSet`, and `NSString`.
686-
687-
When the `NS` prefix is stripped from a non-type, lowercase the
688-
initial word. For example:
689-
690-
<pre>
691-
var NSDateComponentUndefined: Int { get }
692-
</pre>
693-
694-
will become
695-
696-
<pre>
697-
var dateComponentUndefined: Int { get }
698-
</pre>
699-
700673
### Conformance of implementers of compare method
701674

702675
Currently, in comparing protocols, for example developers usually have

0 commit comments

Comments
 (0)