[swift-evolution] [Review] SE-0030 Property Behaviors

Matt Whiteside mwhiteside.dev at gmail.com
Sun Feb 14 16:00:17 CST 2016


Thanks for explaining.  I forgot about access modifiers.

> On Feb 14, 2016, at 12:36, Brent Royal-Gordon <brent at architechies.com> wrote:
> 
>> I’m sorry if this has already been discussed, but what are the drawbacks of putting the variable's behaviors before the ‘var’ keyword?  Like this:
>> 
>> lazy synchronized var x:SomeType
> 
> With no prefix at all, this limits our ability to introduce declaration modifiers in the future. For instance, if the people clamoring for a `local` access modifier win in Swift 4, anyone who wrote a behavior called `local` will be very sad.
> 
> The other problem is, with this declaration:
> 
> 	lazy var array = [1, 2, 3]
> 
> It offers no way to disambiguate between the two meanings of `lazy`:
> 
> 	array.lazy.reset()
> 	array.lazy.map { ... }
> 
> Personally, if we're not going to use the `[]` syntax, I think we should use the `@` prefix and think of all uses of `@` throughout the language as eventual targets for behavior-ization (even if we don't get around to most of them in Swift 3, or some of them ever). It would be nice to have a rational explanation for what `@` means. But I'm reasonably happy with the `[]` syntax.

Yes, the ‘@‘ seems worth thinking about here.

Matt


More information about the swift-evolution mailing list