Skip to content

[docs] Add documentation for underscored attributes. #37854

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
155765d
[docs] Add documentation for underscored attributes.
varungandhi-apple Jun 9, 2021
291be83
Fix typo: It's -> Its.
varungandhi-apple Jun 12, 2021
b6d9185
Reflow text description for @_spi.
varungandhi-apple Jun 12, 2021
546a761
Fix URL for SE-0302.
varungandhi-apple Jun 12, 2021
79527d7
Add some more definitions + cleanup.
varungandhi-apple Jun 13, 2021
c6c1e3b
Update notes on unsafeMainActor and unsafeSendable.
varungandhi-apple Jun 14, 2021
6c3fd79
Added notes on _effects, _optimize and _semantics + cleanup.
varungandhi-apple Jun 14, 2021
ab1bfe9
Fix missing backticks and grammar.
varungandhi-apple Jun 15, 2021
ae177a0
Add notes for _nonoverride, _typeEraser, _show_in_interface + formatt…
varungandhi-apple Jun 15, 2021
88601eb
Add link for library evolution based on xwu's feedback.
varungandhi-apple Jul 23, 2021
4b4f0ab
Remove TODO from @ _alwaysEmitIntoClient description.
varungandhi-apple Jul 23, 2021
3cb94f8
Add note for _borrowed.
varungandhi-apple Jul 23, 2021
8b1adba
Add notes for _fixed_layout, _hasInitialValue and _hasStorage.
varungandhi-apple Jul 23, 2021
5099e88
Clarify wording for _show_in_interface.
varungandhi-apple Jul 23, 2021
57d61c0
Improve wording for _nonoverride.
varungandhi-apple Jul 23, 2021
20a2e48
Add notes for _distributedActorIndependent and _inheritActorContext.
varungandhi-apple Jul 23, 2021
4267d90
Add note for _staticInitializeObjCMetdata.
varungandhi-apple Jul 23, 2021
8dc0df2
Add note for _specializeExtension.
varungandhi-apple Jul 23, 2021
9100055
Add note for _objc_non_lazy_realization.
varungandhi-apple Jul 27, 2021
24d273f
Improved wording for realization and _objc_non_lazy_realization.
varungandhi-apple Jul 27, 2021
9ef9efd
Adjust wording for _disfavoredOverload to emphasize usage guidelines.
varungandhi-apple Jul 27, 2021
cd13dad
Add note for _weakLinked.
varungandhi-apple Jul 29, 2021
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
43 changes: 43 additions & 0 deletions docs/Lexicon.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ and the combination of module path + access path is an "import path".)

See `ImportPath` and the types nested inside it for more on this.

## access pattern

Defines how some particular storage (a property or a subscript) is accessed.
For example, when accessing a property `let y = a.x`, the compiler could potentially
use `get` accessor or the `_read` accessor. Similarly, for a modification like
`a.x += 1`, the compiler could use `get` + `set` or it could use `_modify`.

The access pattern can differ for call-sites which can/cannot see the underlying
implementation. Clients which cannot see the underlying implementation are said
to use the conservative access pattern.

## archetype

A placeholder for a generic parameter or an associated type within a
Expand Down Expand Up @@ -476,6 +487,38 @@ See [mandatory passes](#mandatory-passes--mandatory-optimizations).
An implicit representation change that occurs when a value is used with
a different [abstraction pattern](#abstraction-pattern) from its current representation.

## realization

The process of initializing an ObjC class for use by the ObjC runtime.
This consists of allocating runtime tracking data, fixing up method lists
and attaching categories.

This is distinct from the initialization performed by `+initialize`, which
happens only when the first message (other than `+load`) is sent to the class.

The order of operations is: realization, followed by `+load` (if present),
followed by `+initialize`. There are few cases where these can happen
at different times.

- Common case (no `+load` or special attributes): Realization is lazy and
happens when the first message is sent to a class. After that, `+initialize`
is run.
- If the class has a `+load` method: `+load`, as the name suggests, runs at
load time; it is the ObjC equivalent of a static initializer in C++. For
such a class, realization eagerly happens at load time before `+load` runs.
(Fun aside: C++ static initializers run after `+load`.) `+initialize` still
runs lazily on the first message.
- If the class is marked [`@_objc_non_lazy_realization`](/docs/ReferenceGuides/UnderscoredAttributes.md#_objc_non_lazy_realization):
Realization happens at load time. `+initialize` still runs lazily on the first
message.

It's possible to create a class that is realized but not initialized by
using a runtime function like `objc_getClass` before the class has been used.

See also: Mike Ash's blog post on
[Objective-C Class Loading and Initialization](https://www.mikeash.com/pyblog/friday-qa-2009-05-22-objective-c-class-loading-and-initialization.html),
which covers `+load` and `+initialize` in more detail.

## refutable pattern

A pattern that may not always match. These include patterns such as:
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ documentation, please create a thread on the Swift forums under the
<!-- NOTE: Outdated -->
- [Lexicon.md](/docs/Lexicon.md):
Canonical reference for terminology used throughout the project.
- [UnderscoredAttributes.md](/docs/ReferenceGuides/UnderscoredAttributes.md):
Documents semantics for underscored (unstable) attributes.

### ABI

Expand Down
Loading