[swift-evolution] Proposal - Allow properties in Extensions

Nutchaphon Rewik nRewik at outlook.com
Fri Dec 18 13:42:39 CST 2015

I only see the benefits on this.

  1.  We don't have to store all states in one file. States can be stored separately. So, we can write code in more composition style.
  2.  We can add new states to the existing type. Not just NSObject subclass with associated object.

protocol Incrementer{

   func increase()

extension Incrementer{

   var count = 1 //
 allows stored properties

    func increase(){

        count = count + 1



> On Dec 8, 2015, at 10:51 AM, Kevin Kachikian via swift-evolution <swift-evolution at swift.org<https://lists.swift.org/mailman/listinfo/swift-evolution>> wrote:
> I'd like to proposal to the Swift community and discuss the advantages and disadvantages of adding modifiable properties to extensions (in addition to the already existing computed properties, instance methods, subscripts, etc.):
> extension SomeType {
>       var aNewProperty: Int
>       var anotherVariable: String
>       var aThirdOne: MyStruct
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/8cb2acb8/attachment.html>

More information about the swift-evolution mailing list