Objective‑C identifiers are derived from Slice identifiers. The exact Objective‑C identifier that is generated depends on the context. For types that are nested in modules (and hence have global visibility in Objective‑C), the generated Objective‑C identifiers are prefixed with their module prefix, as discussed in
Section 18.3. Slice identifiers that do not have global visibility (such as operation names and structure members) do not use the module prefix and are preserved without change. For example, consider the following Slice definition:
If a Slice identifier is the same as an Objective‑C keyword, the corresponding Objective‑C identifier has an underscore suffix. For example, Slice
while maps to Objective‑C
while_.
In some cases, the Objective‑C mapping generates more than one identifier for a given Slice construct. For example, an interface
Intf generates the identifiers
EXIntf and
EXIntfPrx. If a Slice identifier happens to be an Objective‑C keyword, the underscore suffix applies only where necessary, so an interface while generates
EXWhile and
EXWhilePrx.
This is a legal Slice definition. However, the generated exception class derives from
NSException, which defines a
reason method. To avoid hiding the method in the base class, the generated exception class maps the Slice
reason member to the Objective‑C property
reason_, just as it would for a keyword.