[Review] SE-0030 Property Behaviors


(Patrick Smith) #1

Hi all,
Has the following syntax for applying behaviors been considered?
class Example { var foo: Int { @json(key="bar") // `internal` by default }}
If the behavior is not public, then all the outside world sees is `var foo: Int`, which is consistent as what is written on the first line of the declaration.
It’s at the same level as a `get`, `set`, `didSet` etc, and just like those, it’s an implementation detail wrapped inside the property declaration. There is a clear hierarchy.
I think is more readable, especially if any attribute was a closure.
For now, before composability support only one single behavior is allowed, but this also considers legibility for multiple behavior declarations.
Kind Regards,
Patrick