[swift-evolution] Protocols and var { get }

Howard Lovatt howard.lovatt at gmail.com
Sat Jan 30 00:49:58 CST 2016


Scala uses their equivalent of let ... instead of var ... { get }. In Scala
let ... Always means var ... { get }. Not a problem in Scala only having
one concept. I think it is a possibility for Swift.

On Saturday, 30 January 2016, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:

> > So what about protocols requiring ‘var … { get }’ syntax for read only
> properties? Is there some sort of underlying reason for this confusing
> syntax instead of ‘let …’? Now that Swift allows deferred initialization of
> lets does this requirement make sense?
>
> `let` doesn't mean "no setter", it means "constant". For instance, you
> can't make a `weak let`, because the `weak` implies the variable can be
> nilled. There's no way to require a constant in a protocol, but if there
> were one, that's what `let ...` would mean.
>
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <javascript:;>
> https://lists.swift.org/mailman/listinfo/swift-evolution
>


-- 
  -- Howard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160130/f20faaaa/attachment.html>


More information about the swift-evolution mailing list