Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Style.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 本の構造

最終更新日: 2024/2/25
原文: https://github.com/apple/swift-book/blob/main/Style.md
最終更新日: 2025/10/12
原文: https://github.com/swiftlang/swift-book/blob/main/Style.md

TSPL は 3 つの主なパートに加えて、補完的な機能を提供するいくつかの序文に分かれています。

Expand Down
9 changes: 6 additions & 3 deletions language-guide/concurrency.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 並行処理\(Concurrency\)

最終更新日: 2025/06/28
最終更新日: 2025/10/12
原文: https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html

非同期操作を行う。
Expand Down Expand Up @@ -271,7 +271,7 @@ task.cancel() // Prints "キャンセルされた!"

前のセクションで説明されている構造化された並行処理のアプローチに加えて、Swift は非構造化並行処理\(_unstructured concurrency_\)もサポートしています。タスクグループの一部のタスクとは異なり、非構造化タスク\(_unstructured task_\)には親タスクがありません。どんな方法で使われたとしても、非構造化タスクを完全に柔軟に管理することができます。しかし、それらの正しい動作を保証することは完全に開発者の責任です。

周囲のコードと同様に実行される非構造化タスクを作成するには、[Task.init\(priority:operation:\)](https://developer.apple.com/documentation/swift/task/3856790-init) イニシャライザを呼びます。デフォルトで、現在のタスクと同じアクター隔離、優先度、およびタスクローカル状態で実行されます。周囲のコードからより独立した非構造化タスク(より具体的には切り離されたタスク\(_detached task_\)として知られるもの)を作成するには、[Task.detached\(priority:operation:\)](https://developer.apple.com/documentation/swift/task/3856786-detached) 関数を呼び出します。新しいタスクは、デフォルトでどのアクターにも隔離されずに実行され、現在のタスクの優先度やタスクローカル状態を継承しません。これらの操作はいずれも操作可能なタスクを返します。例えば、その結果を待機したり、キャンセルしたりできます。
周囲のコードと同様に実行される非構造化タスクを作成するには、[`Task.init(name:priority:operation:)`][] イニシャライザを呼びます。デフォルトで、現在のタスクと同じアクター隔離、優先度、およびタスクローカル状態で実行されます。周囲のコードからより独立した非構造化タスク(より具体的には切り離されたタスク\(_detached task_\)として知られるもの)を作成するには、[`Task.detached(name:priority:operation:)`][] 関数を呼び出します。新しいタスクは、デフォルトでどのアクターにも隔離されずに実行され、現在のタスクの優先度やタスクローカル状態を継承しません。これらの操作はいずれも操作可能なタスクを返します。例えば、その結果を待機したり、キャンセルしたりできます。

```swift
let newPhoto = // ... ある写真データ ...
Expand All @@ -283,6 +283,9 @@ let result = await handle.value

切り離されたタスクの管理の詳細については、[Task](https://developer.apple.com/documentation/swift/task)を参照ください。

[`Task.init(name:priority:operation:)`]: https://developer.apple.com/documentation/swift/task/init(name:priority:operation:)-43wmk
[`Task.detached(name:priority:operation:)`]: https://developer.apple.com/documentation/swift/task/detached(name:priority:operation:)-795w1

## 隔離

前のセクションでは、並行処理を分割するアプローチについて説明しました。その処理には、アプリの UI などの共有データの変更が含まれる場合があります。コードの異なる部分が同じデータを同時に変更できる場合、データ競合が発生するリスクがあります。Swift はコード内のデータ競合から保護します。データを読み取ったり変更したりするたびに、Swift は他のコードが同時にそれを変更していないことを保証します。この保証はデータ隔離\(_data isolation_\)と呼ばれます。データを隔離するには、主に 3 つの方法があります。
Expand Down Expand Up @@ -508,4 +511,4 @@ struct FileDescriptor {
extension FileDescriptor: Sendable {}
```

unavailable 準拠を使用して、[プロトコルへの暗黙の準拠\(Implicit Conformance to a Protocol\)](./protocols.md#プロトコルへの暗黙の準拠implicit-conformance-to-a-protocol)で説明されているように、プロトコルに対する暗黙的な準拠を抑制することもできます。
unavailable 準拠を使用して、[プロトコルへの暗黙の準拠\(Implicit Conformance to a Protocol\)](./protocols.md#プロトコルへの暗黙の準拠implicit-conformance-to-a-protocol)で説明されているように、プロトコルに対する暗黙的な準拠を抑制することもできます。
6 changes: 3 additions & 3 deletions language-guide/macros.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# マクロ\(Macros\)

最終更新日: 2025/02/22
最終更新日: 2025/10/12
原文: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/macros

コンパイル時にコードを生成するためにマクロを使用します。
Expand Down Expand Up @@ -256,7 +256,7 @@ targets: [

```swift
dependencies: [
.package(url: "https://github.com/apple/swift-syntax", from: "509.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", from: "509.0.0"),
],
```

Expand Down Expand Up @@ -351,4 +351,4 @@ let expectedDescription =
precondition(transformedSF.description == expectedDescription)
```

上記の例では、`precondition` を使ってマクロをテストしていますが、代わりにテストフレームワークを使うこともできます。
上記の例では、`precondition` を使ってマクロをテストしていますが、代わりにテストフレームワークを使うこともできます。
4 changes: 2 additions & 2 deletions language-reference/attributes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 属性\(Attributes\)

最終更新日: 2025/5/31
最終更新日: 2025/10/12
原文: https://docs.swift.org/swift-book/ReferenceManual/Attributes.html

宣言と型に情報を追加する。
Expand Down Expand Up @@ -983,4 +983,4 @@ switch の case 属性は、switch 文のケースにのみ適用できます。
> *balanced-token* → **`[`** *balanced-tokens*_?_ **`]`** \
> *balanced-token* → **`{`** *balanced-tokens*_?_ **`}`** \
> *balanced-token* → 任意の識別子、キーワード、リテラル、または演算子 \
> *balanced-token* → **`(`**, **`)`**, **`[`**, **`]`**, **`{`**, または **`}`** を除く任意の句読点
> *balanced-token* → **`(`**, **`)`**, **`[`**, **`]`**, **`{`**, または **`}`** を除く任意の句読点
6 changes: 3 additions & 3 deletions language-reference/declarations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 宣言\(Declarations\)

最終更新日: 2025/7/6
最終更新日: 2025/10/12
原文: https://docs.swift.org/swift-book/ReferenceManual/Declarations.html

型、演算子、変数、およびその他の名前と構造を紹介する。
Expand Down Expand Up @@ -1511,7 +1511,7 @@ _parameters_ または _return type_ がオーバーロードしているもの
macro <#name#> = <#macro implementation#>
```

*マクロ実装*は別のマクロで、このマクロの展開を行うコードの場所を示しています。マクロの展開を実行するコードは別の Swift プログラムで、[SwiftSyntax](http://github.com/apple/swift-syntax/)モジュールを使用して Swift コードとやり取りします。Swift 標準ライブラリから `externalMacro(module:type:)` マクロを呼び出し、マクロの実装を含む型の名前と、その型を含むモジュールの名前を渡します。
*マクロ実装*は別のマクロで、このマクロの展開を行うコードの場所を示しています。マクロの展開を実行するコードは別の Swift プログラムで、[SwiftSyntax](http://github.com/swiftlang/swift-syntax/)モジュールを使用して Swift コードとやり取りします。Swift 標準ライブラリから `externalMacro(module:type:)` マクロを呼び出し、マクロの実装を含む型の名前と、その型を含むモジュールの名前を渡します。

マクロは、関数と同じ形でオーバーロードすることができます。
マクロ宣言は、ファイルスコープにのみ表示されます。
Expand Down Expand Up @@ -1707,4 +1707,4 @@ Swift は、open、public、internal、file private、private の 5 つのレベ
>
> *mutation-modifier* → **`mutating`** | **`nonmutating`**
>
> *actor-isolation-modifier* → **`nonisolated`**
> *actor-isolation-modifier* → **`nonisolated`**
4 changes: 2 additions & 2 deletions language-reference/statements.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 文\(Statements\)

最終更新日: 2024/6/23
最終更新日: 2025/10/12
原文: https://docs.swift.org/swift-book/ReferenceManual/Statements.html

式を分類し、実行の流れを制御する。
Expand Down Expand Up @@ -665,7 +665,7 @@ print("Compiled with the Swift 5 compiler or later in a Swift mode earlier than

### <a id="compile-time-diagnostic-statement">コンパイル時診断文\(Compile-Time Diagnostic Statement\)</a>

Swift 5.9 より前のバージョンでは、コンパイル中に `#warning` と `#error` ステートメントが診断結果を出力します。この動作は、現在 Swift 標準ライブラリの[`warning(_:)`](http://developer.apple.com/documentation/swift/documentation/swift/warning(_:))と[`error(_:)`](http://developer.apple.com/documentation/swift/documentation/swift/error(_:))マクロによって提供されています。
Swift 5.9 より前のバージョンでは、コンパイル中に `#warning` と `#error` ステートメントが診断結果を出力します。この動作は、現在 Swift 標準ライブラリの[`warning(_:)`](https://developer.apple.com/documentation/swift/warning(_:))と[`error(_:)`](https://developer.apple.com/documentation/swift/error(_:))マクロによって提供されています。

## <a id="availability-condition">アベイラビリティ条件\(Availability Condition\)</a>

Expand Down