@@ -355,14 +355,14 @@ example using methods::
355
355
}
356
356
357
357
extension Point2D {
358
- @inlineable public func distanceTo(_ other: Point2D) -> Double {
358
+ @inlineable public func distance(to other: Point2D) -> Double {
359
359
let deltaX = self.x - other.x
360
360
let deltaY = self.y - other.y
361
361
return sqrt(deltaX*deltaX + deltaY*deltaY)
362
362
}
363
363
}
364
364
365
- As written, this ``distanceTo `` method is not safe to inline. The next release
365
+ As written, this ``distance `` method is not safe to inline. The next release
366
366
of the library could very well replace the implementation of ``Point2D `` with a
367
367
polar representation::
368
368
@@ -371,15 +371,16 @@ polar representation::
371
371
public init(x: Double, y: Double) { … }
372
372
}
373
373
374
- and the ``x `` and ``y `` properties have now disappeared. To avoid this, the bodies of inlineable functions have the following restrictions:
374
+ and the ``x `` and ``y `` properties have now disappeared. To avoid this, the
375
+ bodies of inlineable functions have the following restrictions:
375
376
376
377
- They may not define any local types (other than typealiases).
377
378
378
379
- They must not reference any ``private `` or ``fileprivate `` entities, except
379
- for those marked ``@always_emit_into_client `` (see below).
380
+ for those marked ``@alwaysEmitIntoClient `` (see below).
380
381
381
382
- They must not reference any ``internal `` entities except for those that have
382
- been `versioned `_ and those declared ``@always_emit_into_client ``. See below
383
+ been `versioned `_ and those declared ``@alwaysEmitIntoClient ``. See below
383
384
for a discussion of versioning internal API.
384
385
385
386
- They must not reference any entities from the current module introduced
@@ -393,7 +394,7 @@ as the current body makes sense when deploying against an earlier version of
393
394
the library.
394
395
395
396
396
- ``@always_emit_into_client ``
397
+ ``@alwaysEmitIntoClient ``
397
398
----------------------------
398
399
399
400
The normal ``@inlineable `` attribute states that a function *may * be inlined
@@ -406,13 +407,13 @@ that the function is emitted into the client:
406
407
- The function is a helper for an ``@inlineable `` function, but should not be
407
408
part of the library's ABI.
408
409
409
- This is handled by the ``@always_emit_into_client `` attribute. If one of these
410
+ This is handled by the ``@alwaysEmitIntoClient `` attribute. If one of these
410
411
functions is referenced by a client module, its implementation is always copied
411
- into the client module. ``@always_emit_into_client `` functions are subject to
412
+ into the client module. ``@alwaysEmitIntoClient `` functions are subject to
412
413
the same restrictions as regular ``@inlineable `` functions, as described above.
413
414
The description "inlineable" collectively refers to declarations marked with
414
- ``@inlineable `` and declarations marked with ``@always_emit_into_client ``. A
415
- declaration may not be both ``@inlineable `` and ``@always_emit_into_client ``.
415
+ ``@inlineable `` and declarations marked with ``@alwaysEmitIntoClient ``. A
416
+ declaration may not be both ``@inlineable `` and ``@alwaysEmitIntoClient ``.
416
417
417
418
.. note ::
418
419
@@ -421,60 +422,60 @@ declaration may not be both ``@inlineable`` and ``@always_emit_into_client``.
421
422
.. admonition :: TODO
422
423
423
424
All of these names are provisional. In particular, It Would Be Nice(tm) if
424
- the final name for ``@always_emit_into_client `` was a variation of the
425
+ the final name for ``@alwaysEmitIntoClient `` was a variation of the
425
426
final name for ``@inlineable ``.
426
427
427
428
Any local functions or closures within an inlineable function are themselves
428
- treated as ``@always_emit_into_client ``. This is important in case it is
429
+ treated as ``@alwaysEmitIntoClient ``. This is important in case it is
429
430
necessary to change the inlineable function later; existing clients should not
430
431
be depending on internal details of the previous implementation.
431
432
432
- ``@always_emit_into_client `` is *not * a versioned attribute, and therefore it
433
+ ``@alwaysEmitIntoClient `` is *not * a versioned attribute, and therefore it
433
434
may not be added to a declaration that was versioned in a previous release of a
434
435
library. An existing ``@inlineable `` function may not be changed to an
435
- ``@always_emit_into_client `` function or vice versa.
436
+ ``@alwaysEmitIntoClient `` function or vice versa.
436
437
437
438
It is a `binary-compatible source-breaking change ` to completely remove a
438
- public entity marked ``@always_emit_into_client `` from a library. (Non-public,
439
+ public entity marked ``@alwaysEmitIntoClient `` from a library. (Non-public,
439
440
non-versioned entities may always be removed from a library; they are not part
440
441
of its API or ABI.)
441
442
442
- Removing ``@always_emit_into_client `` from a public entity is also a
443
+ Removing ``@alwaysEmitIntoClient `` from a public entity is also a
443
444
`binary-compatible source-breaking change `, and requires updating the
444
- availability of that entity. Removing ``@always_emit_into_client `` from a
445
+ availability of that entity. Removing ``@alwaysEmitIntoClient `` from a
445
446
non-public entity is always permitted.
446
447
447
448
.. note ::
448
449
449
- As an example, if an API is marked ``@always_emit_into_client `` in version
450
+ As an example, if an API is marked ``@alwaysEmitIntoClient `` in version
450
451
1 of a library, and the attribute is removed in version 2, the entity
451
452
itself must be updated to state that it is introduced in version 2. This is
452
453
equivalent to removing the entity and then adding a new one with the same
453
454
name.
454
455
455
456
Although they are not a supported feature for arbitrary libraries at this time,
456
- `transparent `_ functions are implicitly marked ``@always_emit_into_client ``.
457
+ `transparent `_ functions are implicitly marked ``@alwaysEmitIntoClient ``.
457
458
458
459
.. _transparent : https://github.com/apple/swift/blob/master/docs/TransparentAttr.rst
459
460
460
461
.. note ::
461
462
462
- Why have both ``@inlineable `` and ``@always_emit_into_client ``? Because for
463
+ Why have both ``@inlineable `` and ``@alwaysEmitIntoClient ``? Because for
463
464
a larger function, like ``MutableCollectionType.sort ``, it may be useful to
464
465
provide the body to clients for analysis, but not duplicate code when not
465
- necessary. ``@always_emit_into_client `` also may not be added to an
466
+ necessary. ``@alwaysEmitIntoClient `` also may not be added to an
466
467
existing versioned declaration.
467
468
468
469
.. admonition :: TODO
469
470
470
- What does it mean for an ``@always_emit_into_client `` declaration to
471
+ What does it mean for an ``@alwaysEmitIntoClient `` declaration to
471
472
satisfy a protocol requirement?
472
473
473
474
474
475
Default Argument Expressions
475
476
----------------------------
476
477
477
- Default argument expressions are implemented as ``@always_emit_into_client ``
478
+ Default argument expressions are implemented as ``@alwaysEmitIntoClient ``
478
479
functions and thus are subject to the same restrictions as inlineable
479
480
functions. A default argument implicitly has the same availability as the
480
481
function it is attached to.
@@ -565,7 +566,7 @@ clients to access them more efficiently. This restricts changes a fair amount:
565
566
566
567
Any inlineable accessors must follow the rules for `inlineable functions `_, as
567
568
described above. Top-level computed variables may be marked
568
- ``@always_emit_into_client ``, with the same restrictions as for functions.
569
+ ``@alwaysEmitIntoClient ``, with the same restrictions as for functions.
569
570
570
571
Note that if a constant's initial value expression has any observable side
571
572
effects, including the allocation of class instances, it must not be treated
@@ -600,7 +601,7 @@ layout.
600
601
601
602
.. admonition :: TODO
602
603
603
- We need to pin down how this, and the ``@fixed_contents `` attribute below,
604
+ We need to pin down how this, and the ``@fixedContents `` attribute below,
604
605
interacts with the "Behaviors" proposal. Behaviors that just change the
605
606
accessors of a property are fine, but those that provide new entry points
606
607
are trickier.
@@ -616,7 +617,7 @@ Methods and Initializers
616
617
617
618
For the most part struct methods and initializers are treated exactly like
618
619
top-level functions. They permit all of the same modifications and can also be
619
- marked ``@inlineable `` or ``@always_emit_into_client ``, with the same
620
+ marked ``@inlineable `` or ``@alwaysEmitIntoClient ``, with the same
620
621
restrictions. Inlineable initializers must always delegate to another
621
622
initializer, since new properties may be added between new releases. For the
622
623
same reason, initializers declared outside of the struct's module must always
@@ -631,7 +632,7 @@ all of the same modifications, and also allow adding or removing an initial
631
632
value entirely.
632
633
633
634
Struct properties can also be marked ``@inlineable `` or
634
- ``@always_emit_into_client ``, with the same restrictions as for top-level
635
+ ``@alwaysEmitIntoClient ``, with the same restrictions as for top-level
635
636
bindings. An inlineable stored property may not become computed, but the offset
636
637
of its storage within the struct is not necessarily fixed.
637
638
@@ -642,7 +643,7 @@ of its storage within the struct is not necessarily fixed.
642
643
be fixed. This would have to be balanced against other goals for struct
643
644
layout.
644
645
645
- Only computed properties may be marked ``@always_emit_into_client ``.
646
+ Only computed properties may be marked ``@alwaysEmitIntoClient ``.
646
647
647
648
Like top-level constants, it is *not * safe to change a ``let `` property into a
648
649
variable or vice versa. Properties declared with ``let `` are assumed not to
@@ -660,7 +661,7 @@ stored subscripts. This means that the following changes are permitted:
660
661
- Changing the body of an accessor.
661
662
662
663
Like properties, subscripts can be marked ``@inlineable `` or
663
- ``@always_emit_into_client ``, which restricts the set of changes:
664
+ ``@alwaysEmitIntoClient ``, which restricts the set of changes:
664
665
665
666
- Adding a versioned setter is still permitted.
666
667
- Adding or removing a non-public, non-versioned setter is still permitted.
@@ -714,10 +715,10 @@ provides.
714
715
Fixed-Contents Structs
715
716
----------------------
716
717
717
- To opt out of this flexibility, a struct may be marked ``@fixed_contents ``.
718
+ To opt out of this flexibility, a struct may be marked ``@fixedContents ``.
718
719
This promises that no stored properties will be added to or removed from the
719
720
struct, even non-public ones. Additionally, all versioned instance stored
720
- properties in a ``@fixed_contents `` struct are implicitly declared
721
+ properties in a ``@fixedContents `` struct are implicitly declared
721
722
``@inlineable `` (as described above for top-level variables). In effect:
722
723
723
724
- Reordering all members, including stored properties, is still permitted.
@@ -757,12 +758,12 @@ still be modified in limited ways:
757
758
its version).
758
759
759
760
An initializer of a fixed-contents struct may be declared ``@inlineable `` or
760
- ``@always_emit_into_client `` even if it does not delegate to another
761
+ ``@alwaysEmitIntoClient `` even if it does not delegate to another
761
762
initializer, as long as the ``@inlineable `` attribute, or the initializer
762
- itself, is not introduced earlier than the ``@fixed_contents `` attribute and
763
+ itself, is not introduced earlier than the ``@fixedContents `` attribute and
763
764
the struct has no non-versioned stored properties.
764
765
765
- A ``@fixed_contents `` struct is *not * guaranteed to use the same layout as a C
766
+ A ``@fixedContents `` struct is *not * guaranteed to use the same layout as a C
766
767
struct with a similar "shape". If such a struct is necessary, it should be
767
768
defined in a C header and imported into Swift.
768
769
@@ -774,7 +775,7 @@ defined in a C header and imported into Swift.
774
775
775
776
.. note ::
776
777
777
- Hypothetically, we could use a different model where a ``@fixed_contents ``
778
+ Hypothetically, we could use a different model where a ``@fixedContents ``
778
779
struct only guarantees the "shape" of the struct, so to speak, while
779
780
leaving all property accesses to go through function calls. This would
780
781
allow stored properties to change their accessors, or (with the Behaviors
@@ -783,17 +784,17 @@ defined in a C header and imported into Swift.
783
784
a simple C-like struct that groups together simple values, with only public
784
785
stored properties and no observing accessors, and having to opt into direct
785
786
access to those properties seems unnecessarily burdensome. The struct is
786
- being declared ``@fixed_contents `` for a reason, after all: it's been
787
+ being declared ``@fixedContents `` for a reason, after all: it's been
787
788
discovered that its use is causing performance issues.
788
789
789
790
Consequently, as a first pass we may just require all stored properties in
790
- a ``@fixed_contents `` struct, public or non-public, to have trivial
791
+ a ``@fixedContents `` struct, public or non-public, to have trivial
791
792
accessors, i.e. no observing accessors and no behaviors.
792
793
793
- ``@fixed_contents `` is a `versioned attribute `. This is so that clients can
794
+ ``@fixedContents `` is a `versioned attribute `. This is so that clients can
794
795
deploy against older versions of the library, which may have a different layout
795
796
for the struct. (In this case the client must manipulate the struct as if the
796
- ``@fixed_contents `` attribute were absent.)
797
+ ``@fixedContents `` attribute were absent.)
797
798
798
799
799
800
Enums
@@ -837,7 +838,7 @@ Initializers
837
838
838
839
For the most part enum initializers are treated exactly like top-level
839
840
functions. They permit all of the same modifications and can also be marked
840
- ``@inlineable `` or ``@always_emit_into_client ``, with the same restrictions.
841
+ ``@inlineable `` or ``@alwaysEmitIntoClient ``, with the same restrictions.
841
842
Unlike struct initializers, enum initializers do not always need to delegate to
842
843
another initializer, even if they are inlineable or declared in a separate
843
844
module.
@@ -1036,7 +1037,7 @@ initializers. An existing initializer may not be marked ``required``.
1036
1037
1037
1038
All of the modifications permitted for top-level functions are also permitted
1038
1039
for class initializers. Convenience initializers may be marked ``@inlineable ``
1039
- or ``@always_emit_into_client ``, with the same restrictions as top-level
1040
+ or ``@alwaysEmitIntoClient ``, with the same restrictions as top-level
1040
1041
functions; designated initializers may not.
1041
1042
1042
1043
@@ -1062,7 +1063,7 @@ top-level functions, but the potential for overrides complicates things a little
1062
1063
Class and instance methods may be marked ``@inlineable ``, with the same
1063
1064
restrictions as struct methods. ``dynamic `` methods may not be marked
1064
1065
``@inlineable ``. Only non-overriding ``final `` methods may be marked
1065
- ``@always_emit_into_client ``.
1066
+ ``@alwaysEmitIntoClient ``.
1066
1067
1067
1068
If an inlineable method is overridden, the overriding method does not need to
1068
1069
also be inlineable. Clients may only inline a method when they can devirtualize
@@ -1102,7 +1103,7 @@ value, as well as adding or removing an initial value entirely.
1102
1103
1103
1104
Both variable and constant properties (on both instances and classes) may be
1104
1105
marked ``@inlineable ``; non-overriding ``final `` computed properties may also
1105
- be marked ``@always_emit_into_client ``. This behaves as described for struct
1106
+ be marked ``@alwaysEmitIntoClient ``. This behaves as described for struct
1106
1107
properties. ``dynamic `` properties may not be marked ``@inlineable ``.
1107
1108
1108
1109
If an inlineable property is overridden, the overriding property does not need
@@ -1127,7 +1128,7 @@ know what to do with the setter and will likely not behave correctly.
1127
1128
1128
1129
Class subscripts may be marked ``@inlineable ``, which behaves as described for
1129
1130
struct subscripts. Non-overriding ``final `` subscripts may also be marked
1130
- ``@always_emit_into_client ``. ``dynamic `` subscripts may not be marked
1131
+ ``@alwaysEmitIntoClient ``. ``dynamic `` subscripts may not be marked
1131
1132
``@inlineable ``.
1132
1133
1133
1134
If an inlineable subscript is overridden, the overriding subscript does not need
@@ -1228,7 +1229,7 @@ A Unifying Theme
1228
1229
1229
1230
So far this document has talked about ways to give up flexibility for several
1230
1231
different kinds of declarations: ``@inlineable `` for functions,
1231
- ``@fixed_contents `` for structs, etc. Each of these has a different set of
1232
+ ``@fixedContents `` for structs, etc. Each of these has a different set of
1232
1233
constraints it enforces on the library author and promises it makes to clients.
1233
1234
However, they all follow a common theme of giving up the flexibility of future
1234
1235
changes in exchange for improved performance and perhaps some semantic
@@ -1271,11 +1272,11 @@ Non-public conformances are never considered versioned, even if both the
1271
1272
conforming type and the protocol are versioned. A conformance is considered
1272
1273
public if and only if both the conforming type and protocol are public.
1273
1274
1274
- Non-public entities declared ``@always_emit_into_client `` may not be versioned.
1275
+ Non-public entities declared ``@alwaysEmitIntoClient `` may not be versioned.
1275
1276
1276
1277
.. admonition :: TODO
1277
1278
1278
- ...but we do need a way for ``@always_emit_into_client `` functions to
1279
+ ...but we do need a way for ``@alwaysEmitIntoClient `` functions to
1279
1280
declare the minimum version of the library they can be used in, right?
1280
1281
Syntax?
1281
1282
@@ -1314,7 +1315,7 @@ is clearly not safe: older versions of the library will not expose the entity
1314
1315
as part of their ABI. What may be less obvious is that the fragility attributes
1315
1316
likewise are not safe to backdate, even if you know the attributes could have
1316
1317
been added in the past. To give one example, the presence of ``@closed `` or
1317
- ``@fixed_contents `` may affect the layout and calling conventions for an enum
1318
+ ``@fixedContents `` may affect the layout and calling conventions for an enum
1318
1319
or struct.
1319
1320
1320
1321
As the sole exception, it is safe to backdate ``@inlineable `` on a top-level
@@ -1529,7 +1530,7 @@ for verification. Important cases include but are not limited to:
1529
1530
- Unsafe `backdating <#backdating >`_.
1530
1531
1531
1532
- Unsafe modifications to entities marked with fragility attributes, such as
1532
- adding a stored property to a ``@fixed_contents `` struct.
1533
+ adding a stored property to a ``@fixedContents `` struct.
1533
1534
1534
1535
Wherever possible, this tool should also check for `binary-compatible
1535
1536
source-breaking changes <binary-compatible source-breaking change> `, such as
0 commit comments