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

Data Racy Safety Editing #109

Merged
merged 11 commits into from
Jul 2, 2024
26 changes: 10 additions & 16 deletions Guide.docc/DataRaceSafety.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ you are doing so statically. Isolation can be a part of these static
declarations.

There are cases, however, where the type system alone cannot sufficiently
describe a system's behavior. An example could be an Objective-C type
describe runtime behavior. An example could be an Objective-C type
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

awkward duplication of the word "system" here with different meaings.

that has been exposed to Swift. This declaration, made outside of Swift code,
may not provide enough information to the compiler to ensure safe usage. To
accommodate these situations, there are additional features that allow you
Expand Down Expand Up @@ -130,8 +130,7 @@ access from any other domain.

Actors give the programmer a way to define an isolation domain,
along with methods that operate within that domain.
All stored instance properties of an actor are isolated to the enclosing
actor instance.
All stored properties of an actor are isolated to the enclosing actor instance.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Change wording to "stored properties" to match TSPL and also avoid duplicating the word "instance" within the sentence.


```swift
actor Island {
Expand Down Expand Up @@ -226,7 +225,7 @@ but that doesn't mean you must always manually start one.
Typically, asynchronous functions do not need to be aware of the
task running them.
In fact, tasks can often begin at a much higher level,
within an application framework, or even at the root of a program.
within an application framework, or even at the entry point of the program.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what is "the root of a program"?

Copy link
Member

Choose a reason for hiding this comment

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

hehe yeah... well, not where the leafs are! 🥬

Good rewording


Tasks may run concurrently with one another,
but each individual task only executes one function at a time.
Expand All @@ -243,7 +242,7 @@ actor instance, a global actor, or could be non-isolated.
This isolation can be established manually, but can also be inherited
automatically based on context.
Task isolation, just like all other Swift code, determines what mutable state
they can access.
is accessible.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"they" is quite unclear here.


Tasks can run both synchronous and asynchronous code. Regardless of the
structure and how many tasks are involved, functions in the same isolation
Expand Down Expand Up @@ -388,7 +387,7 @@ The Swift Programming Language.
Isolation domains protect their mutable state, but useful programs need more
than just protection. They have to communicate and coordinate,
often by passing data back and forth.
Moving values into or out of an isolation domain is known as crossing an
Moving values into or out of an isolation domain is known as _crossing_ an
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New concepts are emphasized throughout this document.

isolation boundary.

Values are only ever permitted to cross an isolation boundary where there
Expand All @@ -406,10 +405,8 @@ They can even be executed in multiple, different domains.

In some cases, all values of a particular type are safe to pass across
isolation boundaries because thread-safety is a property of the type itself.
This thread-safe property of types is represented by a conformance to the
`Sendable` protocol.
When you see a conformance to `Sendable` in documentation,
it means the given type is thread safe,
This is represented by the `Sendable` protocol.
A conformance to `Sendable` means the given type is thread safe,
Copy link
Collaborator Author

@mattmassicotte mattmassicotte Jun 25, 2024

Choose a reason for hiding this comment

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

Lots of redundancy within this sentences. Plus, referencing "documentation" here is just strange.

and values of the type can be shared across arbitrary isolation domains
without introducing a risk of data races.

Expand All @@ -423,7 +420,7 @@ types in Swift are implicitly `Sendable` when all their stored properties
are also Sendable.
However, this implicit conformance is not visible outside of their
defining module.
Making a class `Sendable` is part of its public API contract,
Making a type `Sendable` is part of its public API contract
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This whole section is about value types!

and must always be done explicitly.

```swift
Expand Down Expand Up @@ -532,16 +529,13 @@ class ChickenValley {
}
```

Being `Sendable`, actor and global-actor-isolated types are always safe
to pass across isolation boundaries.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just re-stating information that has appeared immediately before.


### Reference Types

Unlike value types, reference types cannot be implicitly `Sendable`.
And while they can be made `Sendable`,
doing so comes with a number of constraints.
To make a class `Sendable`, it must contain no mutable state.
And any immutable properties must also be `Sendable`.
To make a class `Sendable` it must contain no mutable state and all
immutable properties must also be `Sendable`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Awkard wording and structure here.

Further, the compiler can only validate the implementation of final classes.

```swift
Expand Down
5 changes: 2 additions & 3 deletions Guide.docc/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Or, you may have been waiting for the Swift 6 release to begin using them.
Regardless of where your project is in this process, this guide provides
concepts and practical help to ease the migration.

Here you will find articles and code examples that will:
You will find articles and code examples here that:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Really don't like the sound of the duplicated "here"


- Explain the concepts used by Swift's data-race safety model.
- Outline a possible way to get started with migration.
Expand All @@ -43,8 +43,7 @@ Here you will find articles and code examples that will:
> Important: The Swift 6 language mode is _opt-in_.
Existing projects will not switch to this mode without configuration changes.
>
> There is an important distinction between the _compiler version_
and _language mode_.
> There is a distinction between the _compiler version_ and _language mode_.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is within a note marked "Important". I don't think restating that this is also important is adding anything.

The Swift 6 compiler supports four distinct language modes: "6", "5", "4.2",
and "4".

Expand Down