[swift-evolution] Proposal - Allow properties in Extensions
Kevin Kachikian
kevyk at mac.com
Fri Dec 18 17:42:58 CST 2015
I’m really glad to see some discussion about this. I think it is an extremely worth while addition to Swift. Chris L. also thought it was a good idea, in general.
If I get a chance I’ll make a formal request to consider it. Anyone else interested in offering it up, officially?
Thanks,
Kevin Kachikian
> On Dec 18, 2015, at 11:42 AM, Nutchaphon Rewik <nRewik at outlook.com> wrote:
>
> I only see the benefits on this.
> 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.
> 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(){
> print(count)
> 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/cd5652ab/attachment.html>
More information about the swift-evolution
mailing list