# Pitch: Property Delegates

**URL:** <https://forums.swift.org/t/pitch-property-delegates/21895>\
**Category:** Pitches\
**Created:** [March 21, 2019, 9:30pm UTC](https://forums.swift.org/t/pitch-property-delegates/21895 "2019-03-21T21:30:09Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![Paul\_Cantrell](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/paul_cantrell/32/16764_2.png) [@Paul\_Cantrell](https://forums.swift.org/u/Paul_Cantrell)\
**Post date:** [March 22, 2019, 12:55am UTC](https://forums.swift.org/t/pitch-property-delegates/21895/18 "2019-03-22T00:55:38Z")

</div>

Love this idea, and I’m excited to see it return! This revised version’s power and simplicity is admirable. The `Lazy<Value>` example is beautiful.

I’d have to sleep on the `by` and `$` syntax, but if they’re not perfect, they feel close.

Though I concede its use cases are few, I’d be sorry to lose this:

> - Delegates used for properties declared within a type cannot refer to the `self` of their enclosing type. This eliminates some use cases (e.g., implementing a `Synchronized` property delegate type that uses a lock defined on the enclosing type), but simplifies the design.

Could delegates take `self` as an explicit argument?

```swift
class C {
    var foo: Synchronized(on: self)
}

```

I’m guessing the answer is “no” because `self` isn’t fully initialized until the property already exists. Is there a future direction for this?

Can a generic type follow `by`?

Given that the proposed syntax doesn’t support nested delegates, would it support writing a generic delegate-wrapping delegate? e.g.

`var foo: Int by NestedDelegate(Copying(), inside: DelayedMutable())`

---

_[View the full topic](https://forums.swift.org/t/pitch-property-delegates/21895)._
