rfc:readonly_properties_v2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:readonly_properties_v2 [2021/07/01 10:16] – nikic | rfc:readonly_properties_v2 [2021/07/20 15:37] (current) – nikic | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2021-06-02 | * Date: 2021-06-02 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.1 | * Target Version: PHP 8.1 | ||
* Implementation: | * Implementation: | ||
Line 153: | Line 153: | ||
</ | </ | ||
- | As the property has no default value, the assignment in the constructor is initializing, | + | As the property has no default value, the assignment in the constructor is initializing, |
- | Readonly static properties are not supported. This is a technical limitation, in that it is not possible to implement readonly static properties non-intrusively. In conjuction | + | Readonly static properties are not supported. This is a technical limitation, in that it is not possible to implement readonly static properties non-intrusively. In conjunction |
==== Inheritance ==== | ==== Inheritance ==== | ||
Line 240: | Line 240: | ||
</ | </ | ||
- | However, it is possible to unset a readonly property prior to initialization, | + | However, it is possible to unset a readonly property prior to initialization, |
<PHP> | <PHP> | ||
Line 326: | Line 326: | ||
This also ensures that a potential future "clone with" implementation will only be able to modify readonly properties from private scope and thus cannot bypass additional invariants imposed by the implementation when used from a different scope. | This also ensures that a potential future "clone with" implementation will only be able to modify readonly properties from private scope and thus cannot bypass additional invariants imposed by the implementation when used from a different scope. | ||
- | This RFC overlaps with the [[rfc: | + | This RFC overlaps with the [[rfc: |
It is worth noting that having a readonly property feature does not preclude introduction of accessors. C# supports both readonly properties and accessors. C# also provides properties with implicit backing storage through accessor syntax, but this is not the only way to do it. For example, Swift has special syntax for asymmetric visibility, rather than specifying visibility on implicitly implemented accessors. | It is worth noting that having a readonly property feature does not preclude introduction of accessors. C# supports both readonly properties and accessors. C# also provides properties with implicit backing storage through accessor syntax, but this is not the only way to do it. For example, Swift has special syntax for asymmetric visibility, rather than specifying visibility on implicitly implemented accessors. | ||
Line 344: | Line 344: | ||
Voting started on 2021-07-01 and closes on 2021-07-15. | Voting started on 2021-07-01 and closes on 2021-07-15. | ||
- | <doodle title=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
</ | </ | ||
rfc/readonly_properties_v2.txt · Last modified: 2021/07/20 15:37 by nikic