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

Brent Royal-Gordon brent at architechies.com
Sun Feb 14 14:36:22 CST 2016


> 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.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list