[swift-evolution] [swift-evolution-announce] [Review] SE-0087: Rename lazy to @lazy
Антон Жилин
antonyzhilin at gmail.com
Wed May 18 03:57:37 CDT 2016
>
> > 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160518/fae069d6/attachment.html>
More information about the swift-evolution
mailing list