Skip to content

Commit c202b31

Browse files
amartini51Colleen Toporek
andcommitted
Incorporate editorial feedback
Edits from <rdar://142849102>. Co-authored-by: Colleen Toporek <colleen_toporek@apple.com>
1 parent 22f2822 commit c202b31

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

TSPL.docc/LanguageGuide/TheBasics.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ checks whether a value is missing before using the value,
3030
and non-optional values are guaranteed to never be missing.
3131

3232
Swift is a safe language,
33-
which means it helps you find and fix several categories of bugs
33+
which means it makes it easier for you find and fix several categories of bugs
3434
as early as possible during the development process,
3535
and lets you guarantee that certain kinds of bugs can't happen.
36-
Type safety helps you to be clear about
36+
Type safety enables you to be clear about
3737
the types of values your code works with.
3838
If part of your code requires a `String`,
3939
type safety prevents you from passing it an `Int` by mistake.
40-
Data safety helps you work with only valid data,
40+
Data safety ensures that you work with valid data only,
4141
not uninitialized memory or deinitialized objects,
4242
and ensures that you work with that data in safe ways ---
4343
even in programs that run multiple pieces of code at the same time.
@@ -573,9 +573,9 @@ Swift provides two signed floating-point number types:
573573
Every value in a Swift program has a type.
574574
Every place you store a value ---
575575
including constants, variables, and properties ---
576-
also has a type,
577-
which you might write explicitly using a type annotation
578-
or which might inferred from an initial value.
576+
also has a type.
577+
You might write the type explicitly using a type annotation,
578+
or Swift might infer the type from an initial value.
579579
Every place in your code where you provide a value,
580580
that value's type must match the place you use it.
581581
For example,
@@ -587,7 +587,7 @@ A type safe language encourages you to be clear about
587587
the types of values your code works with.
588588
Values of one type are never implicitly converted to another type.
589589
However, some types can be explicitly converted.
590-
When building code
590+
When building code,
591591
Swift checks the code for type safety
592592
and flags any mismatched types as errors.
593593

@@ -1799,9 +1799,9 @@ if let definiteString = assumedString {
17991799
## Data Safety
18001800

18011801
In addition to the checks that prevent type mismatches,
1802-
which are described above in <doc:TheBasics#Type-Safety-and-Type-Inference>,
1802+
described above in <doc:TheBasics#Type-Safety-and-Type-Inference>,
18031803
Swift also protects code against working with invalid memory.
1804-
This is known as *data safety* or *memory safety*
1804+
This protection is known as *data safety* or *memory safety*
18051805
and includes the following requirements:
18061806

18071807
- Values are set before being read;
@@ -1826,18 +1826,21 @@ see <doc:Concurrency>.
18261826
Sometimes you need to work outside of the bounds of safety ---
18271827
for example, because of limitations of the language or standard library ---
18281828
so Swift also provides unsafe versions of some APIs.
1829-
When you use types or methods whose name includes words like
1829+
When you use types or methods whose name includes words such as
18301830
"unsafe", "unchecked", or "unmanaged",
18311831
you take on the responsibility for safety.
18321832

18331833
Safe code in Swift can still encounter errors and unexpected failures,
18341834
which might stop the program's execution.
1835-
Safety makes no guarantee about whether your code runs to completion.
1835+
Safety doesn't ensure that your code runs to completion.
18361836
Swift provides several ways to indicate and recover from errors,
18371837
discussed in <doc:TheBasics#Error-Handling>
18381838
and <doc:TheBasics#Assertions-and-Preconditions> below.
18391839
However, in some cases,
18401840
the *only* safe way to handle an error is to stop execution.
1841+
If you need to guarantee that a service never unexpected stops,
1842+
incorporate fault tolerance into its overall architecture,
1843+
so it can recover from any of its components stopping unexpectedly.
18411844

18421845
## Error Handling
18431846

0 commit comments

Comments
 (0)