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

Concurrency > Sendable Types — Clarify intro about non-sendable data #285

Open
Diggory opened this issue Mar 10, 2024 · 4 comments
Open
Labels
Content issue A problem in with the book's prose, code, or figures

Comments

@Diggory
Copy link
Contributor

Diggory commented Mar 10, 2024

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/#Sendable-Types

Description

The last sentence of the first para of the section about Sendable Types is (to me, an uninformed reader) confusingly written and could be ideally be clearer.

The text currently reads:

Some kinds of data can’t be shared between concurrency domains, because that data contains mutable state, but it doesn’t protect against overlapping access.

Perhaps it's just me, but that sentence is confusing. The first part is a negative statement (data cannot be shared) then there's a 'but', so I'm expecting an opposing clause, but instead there's another negative clause (doesn't protect.)

The 'but' is confusing. Should I be expecting the non-sharability to protect 'overlapping access'? (not sure what that term means either.)

Maybe I'm being dim, but I come out of reading that sentence with more questions...

Correction

I'm not sure what the docs should say here. Please clarify why these two concepts are related, and what 'overlapping access' means. Thanks!

@Diggory
Copy link
Contributor Author

Diggory commented Mar 10, 2024

I see that 'overlapping access' is defined later in the book under the 'memory safety' section.

However, I still find the sentence confusing.

@amartini51 amartini51 added the Content issue A problem in with the book's prose, code, or figures label Mar 12, 2024
@amartini51 amartini51 changed the title Concurrency Domains - unclear / confusing sentence Concurrency > Sendable Types — Clarify intro about non-sendable data Mar 12, 2024
@amartini51
Copy link
Member

This sentence should avoid the phrase "overlapping access" — the meaning here isn't exactly the same as how Memory Safety later uses it. Here we mean access from different parts of the program that are running concurrently.

@Diggory
Copy link
Contributor Author

Diggory commented Mar 13, 2024

So, would the following version of the sentence be more suitable?

Some kinds of data can’t be shared between concurrency domains, because that data contains mutable state, and is not protected against concurrent access.

@amartini51
Copy link
Member

I'm looking at the paragraph, and I wonder if we need this sentence at all. I think I wrote it to introduce the problem before showing the solution, but maybe it better for me to rewrite and remove this.

A paragraph later, we say essentially the same thing:

In contrast, some types aren’t safe to pass across concurrency domains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content issue A problem in with the book's prose, code, or figures
Projects
None yet
Development

No branches or pull requests

2 participants