Skip to content

Commit d4fbb38

Browse files
authored
Merge pull request #2969 from kubamracek/section-clarify
SE-0492: Clarify wording (built-in -> standard) and code snippets
2 parents c321e84 + bcf0aca commit d4fbb38

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

proposals/0492-section-control.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Different object file formats (ELF, Mach-O, COFF) have different restrictions an
9292

9393
```swift
9494
#if objectFileFormat(ELF)
95-
@section(".mysection")
95+
@section("mysection")
9696
#elseif objectFileFormat(MachO)
9797
@section("__DATA,mysection")
9898
#endif
@@ -190,19 +190,19 @@ The effects described above are applied to the storage symbols and don’t gener
190190

191191
### Constant expressions
192192

193-
Swift currently does not have a formal notion of a **constant expression**, i.e. an expression with a syntactic form that *guarantees the ability to know it's value at compile-time*. This proposal provides a definition of a "bare minimum" constant expression, with the understanding that this does not cover the language needs in generality, and the expectation that the Swift compiler and language will keep expanding the allowed forms of constant expressions. See [Generalized constant values and expressions](#generalized-constant-values-and-expressions) in Future Directions for further discussion on this.
193+
Swift currently does not have a formal notion of a **constant expression**, i.e. an expression with a syntactic form that *guarantees the ability to know it's value at compile-time*. This proposal provides a definition of a "bare minimum" constant expression, with the understanding that this does not cover the language needs in generality, and with the expectation that the Swift compiler and language will keep expanding the allowed forms of constant expressions in the future. See [Generalized constant values and expressions](#generalized-constant-values-and-expressions) in Future Directions for further discussion on this.
194194

195195
This proposal defines a **constant expression** as being one of:
196196

197-
- an integer literal using any of built-in integer types (Int, UInt, Int8/16/32/64/128, UInt8/16/32/64/128)
197+
- an integer literal using any of standard integer types (Int, UInt, Int8/16/32/64/128, UInt8/16/32/64/128)
198198
- a floating-point literal of type Float or Double
199199
- a boolean literal of type Bool
200200
- a direct reference to a non-generic function using its name (the function itself is not generic, and also it must not be defined in a generic context)
201201
- a direct reference to a non-generic metatype using the type name directly (the type itself is not generic, and also it must not be defined in a generic context), where the type is non-resilient
202202
- a tuple composed of only other constant expressions
203203
- an array literal of type InlineArray composed of only other constant expressions
204204

205-
Explicitly, this definition currently does **not allow** any operators, using any user-defined named types, any other built-in type (e.g. strings, dictionaries, sets), using closures, or referencing any variables by name. See below for examples of valid and invalid constant expressions:
205+
Explicitly, this definition currently does **not allow** any operators, using any user-defined named types, any other standard type (e.g. strings, dictionaries, sets), using closures, or referencing any variables by name. See below for examples of valid and invalid constant expressions:
206206

207207
```swift
208208
@section("...") let a = 42 //
@@ -211,7 +211,7 @@ Explicitly, this definition currently does **not allow** any operators, using an
211211
@section("...") let d = Int.max // ❌ not a literal
212212
@section("...") let e: UInt8 = 42 //
213213
@section("...") let f = UInt8(42) // ❌ not a literal
214-
@section("...") let g: MyCustomExpressibleByIntegerLiteral = 42 // ❌ not a built-in type
214+
@section("...") let g: MyCustomExpressibleByIntegerLiteral = 42 // ❌ not a standard type
215215

216216
@section("...") let composition1 = (1, 2, 3, 2.718, true) //
217217
@section("...") let composition2 = (1, 2, Int.max) // ❌ tuple component not constant
@@ -321,7 +321,7 @@ In some cases, it’s not possible to differentiate on the OS to support multipl
321321
#if objectFileFormat(MachO)
322322
@section("__DATA_CONST,mysection")
323323
#elseif objectFileFormat(ELF)
324-
@section(".mysection")
324+
@section("mysection")
325325
#endif
326326
let value = ...
327327
```
@@ -402,7 +402,7 @@ The requirement to only use string literals as the section names could be lifted
402402
403403
```swift
404404
#if objectFileFormat(ELF)
405-
let mySectionName = ".mysection" // required to be a compile-time value
405+
let mySectionName = "mysection" // required to be a compile-time value
406406
#elseif objectFileFormat(MachO)
407407
let mySectionName = "__DATA,mysection" // required to be a compile-time value
408408
#endif

0 commit comments

Comments
 (0)