[swift-evolution-announce] [Review] SE-0087: Rename lazy to @lazy


(Anton Zhilin) #1

> Swift's rule for attribues/keywords is that keywords usually modify type
of variable; attributes do not.
[citation needed]
As far as I can tell, this is not true at all. Most declaration modifiers
do *not* change the type of anything; as far as I can tell, only
`mutating`, `nonmutating`, and possibly `optional` do. Meanwhile, several
attributes—particularly `@noescape` and `@autoclosure`—*do* change the
type. So where is this belief coming from?

When I wrote "modify type", I did not mean distinction between declaration
and type modifiers.

For example, if @autoclosure was used as @autoclosure Int , then I'd say
that it "changes" its base type.
On the other hand, I'd say that @autoclosure () -> Int "keeps" its base
type.

In the same sense, `lazy` does not have any visible changes on type of its
property.
On the other hand, `weak` effectively changes property type from T to T?
`unowned` effectively changes T to T!

The main driver was actually property behaviours proposal, and I think the
discussion stopped at attribute syntax being most appropriate.
If that changes later, and property behaviours is accepted, we will have to
move @lazy, along with @NSCopying and others, to the new syntax.

- Anton