Skip to content

Commit faef92d

Browse files
authored
Update OwnershipManifesto.md
1 parent 2d37e5b commit faef92d

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

docs/OwnershipManifesto.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ we mean a specific instance of a semantic, user-language value.
218218

219219
For example, consider the following Swift code:
220220

221-
```
221+
```swift
222222
var x = [1,2,3]
223223
var y = x
224224
```
@@ -418,7 +418,7 @@ discussed in the introduction. For example, suppose that
418418
the callee loads a value from its argument, then calls
419419
a function which the optimizer cannot reason about:
420420

421-
```
421+
```swift
422422
extension Array {
423423
mutating func organize(_ predicate: (Element) -> Bool) {
424424
let first = self[0]
@@ -916,7 +916,7 @@ semantically necessary when working with non-copyable types.
916916

917917
We propose to remove this limitation in a straightforward way:
918918

919-
```
919+
```swift
920920
inout root = &tree.root
921921

922922
shared elements = self.queue
@@ -946,7 +946,7 @@ cases to be spelled explicitly:
946946

947947
- A function argument can be explicitly declared `owned`:
948948

949-
```
949+
```swift
950950
func append(_ values: owned [Element]) {
951951
...
952952
}
@@ -960,7 +960,7 @@ cases to be spelled explicitly:
960960

961961
- A function argument can be explicitly declared `shared`.
962962

963-
```
963+
```swift
964964
func ==(left: shared String, right: shared String) -> Bool {
965965
...
966966
}
@@ -994,7 +994,7 @@ cases to be spelled explicitly:
994994

995995
- A method can be explicitly declared `consuming`.
996996

997-
```
997+
```swift
998998
consuming func moveElements(into collection: inout [Element]) {
999999
...
10001000
}
@@ -1060,7 +1060,7 @@ sequence cannot be iterated multiple times, this is a
10601060
This can be explicitly requested by declaring the iteration
10611061
variable `owned`:
10621062

1063-
```
1063+
```swift
10641064
for owned employee in company.employees {
10651065
newCompany.employees.append(employee)
10661066
}
@@ -1083,7 +1083,7 @@ operation on `Collection`.
10831083
This can be explicitly requested by declaring the iteration
10841084
variable `shared`:
10851085

1086-
```
1086+
```swift
10871087
for shared employee in company.employees {
10881088
if !employee.respected { throw CatastrophicHRFailure() }
10891089
}
@@ -1093,7 +1093,7 @@ It is also used by default when the sequence type is known to
10931093
conform to `Collection`, since this is the optimal way of
10941094
iterating over a collection.
10951095

1096-
```
1096+
```swift
10971097
for employee in company.employees {
10981098
if !employee.respected { throw CatastrophicHRFailure() }
10991099
}
@@ -1117,7 +1117,7 @@ operation on `MutableCollection`.
11171117
This must be explicitly requested by declaring the
11181118
iteration variable `inout`:
11191119

1120-
```
1120+
```swift
11211121
for inout employee in company.employees {
11221122
employee.respected = true
11231123
}
@@ -1145,7 +1145,7 @@ languages to conveniently implement iteration. In Swift,
11451145
to follow this pattern, we would need to allow the definition
11461146
of generator functions, e.g.:
11471147

1148-
```
1148+
```swift
11491149
mutating generator iterateMutable() -> inout Element {
11501150
var i = startIndex, e = endIndex
11511151
while i != e {
@@ -1193,7 +1193,7 @@ to invoke one because these would only be used in accessors.
11931193
The idea is that, instead of defining `get` and `set`,
11941194
a storage declaration could define `read` and `modify`:
11951195

1196-
```
1196+
```swift
11971197
var x: String
11981198
var y: String
11991199
var first: String {
@@ -1231,7 +1231,7 @@ For this reason, we propose the `move` function. Conceptually,
12311231
`move` is simply a top-level function in the Swift standard
12321232
library:
12331233

1234-
```
1234+
```swift
12351235
func move<T>(_ value: T) -> T {
12361236
return value
12371237
}
@@ -1270,7 +1270,7 @@ variables are initialized before use.
12701270

12711271
`copy` is a top-level function in the Swift standard library:
12721272

1273-
```
1273+
```swift
12741274
func copy<T>(_ value: T) -> T {
12751275
return value
12761276
}
@@ -1294,7 +1294,7 @@ value is returned. This is useful for several reasons:
12941294

12951295
`endScope` is a top-level function in the Swift standard library:
12961296

1297-
```
1297+
```swift
12981298
func endScope<T>(_ value: T) -> () {}
12991299
```
13001300

@@ -1326,7 +1326,7 @@ every component is statically resolvable to a storage declaration.
13261326
There is some recurring interest in the community in allowing programs
13271327
to abstract over storage, so that you might say:
13281328

1329-
```
1329+
```swift
13301330
let prop = Widget.weight
13311331
```
13321332

@@ -1408,7 +1408,7 @@ a `moveonly` context are also implicitly `moveonly`.
14081408

14091409
A type can be a `moveonly` context:
14101410

1411-
```
1411+
```swift
14121412
moveonly struct Array<Element> {
14131413
// Element and Array<Element> are not assumed to be copyable here
14141414
}
@@ -1420,7 +1420,7 @@ hierarchies of associated types.
14201420

14211421
An extension can be a `moveonly` context:
14221422

1423-
```
1423+
```swift
14241424
moveonly extension Array {
14251425
// Element and Array<Element> are not assumed to be copyable here
14261426
}
@@ -1429,7 +1429,7 @@ moveonly extension Array {
14291429
A type can declare conditional copyability using a conditional
14301430
conformance:
14311431

1432-
```
1432+
```swift
14331433
moveonly extension Array: Copyable where Element: Copyable {
14341434
...
14351435
}
@@ -1450,7 +1450,7 @@ it a non-`moveonly` extension is an error.
14501450

14511451
A function can be a `moveonly` context:
14521452

1453-
```
1453+
```swift
14541454
extension Array {
14551455
moveonly func report<U>(_ u: U)
14561456
}
@@ -1483,7 +1483,7 @@ used to express the unique ownership of resources. For
14831483
example, here is a simple file-handle type that ensures
14841484
that the handle is closed when the value is destroyed:
14851485

1486-
```
1486+
```swift
14871487
moveonly struct File {
14881488
var descriptor: Int32
14891489

0 commit comments

Comments
 (0)