Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-11 Thread David Sweeris via swift-evolution
> On Jul 8, 2016, at 6:45 AM, Adrian Zubarev via swift-evolution > wrote: > > It’s clear that we should decide on when our observer will be executed. In > the example from above I pretended that my observer will be executed after > the observer from the module

Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-11 Thread Chris Lattner via swift-evolution
> On Jul 8, 2016, at 4:43 AM, Tino Heth via swift-evolution > wrote: > > There are (were?) plans for generalized property behaviors; those would be > used to implement lazy, as well as didSet/willSet, and could incorporate many > other things (including injection)

Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-08 Thread Adrian Zubarev via swift-evolution
True story, if you’re doing something heavy and there are tons of calls from your observed property you’d pay with a huge performance decrease. Personally I don’t feel like this would be something that stays in the way of having this handy feature, because it’s always up to us to balance the

Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-08 Thread Adrian Zubarev via swift-evolution
I also would like to mention a problem I see with this ‘feature’. Lets say this is my module: public struct A { public var member1: Int = 42 public var member2: Int = 0 { didSet { self.member1 = self.member2 } } } >From

Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-08 Thread Tino Heth via swift-evolution
There are (were?) plans for generalized property behaviors; those would be used to implement lazy, as well as didSet/willSet, and could incorporate many other things (including injection) Of course, an option to observe variables would be handy — but there's always a price to pay, and you'll

Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-08 Thread Adrian Zubarev via swift-evolution
Thats a good point! Here is some bikeshedding: public extension UIViewController { observe public var view: UIView { willSet { // do something useful here } didSet { // do something useful here } } } An

Re: [swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-08 Thread Leonardo Pessoa via swift-evolution
+1. This would allow us to create observers on any foreign variable. I'm far from a compiler right now but I wouldn't this syntax create a new variable instead of observing an existing one? Even if not, by reading this one could be mislead to believe so. Perhaps you should give it something to

[swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

2016-07-08 Thread Adrian Zubarev via swift-evolution
Hello dear Swift community, I’m not sure if this was discussed before or not, but I really want to know if something like this is welcome for the future Swift version. If this topic was already discussed, I’m apologizing for bringing it back to life in a new thread. Lets say I’ve got a third