# Circling back to \`with\`

**URL:** <https://forums.swift.org/t/circling-back-to-with/2766>\
**Category:** Pitches\
**Created:** [May 25, 2016, 6:28pm UTC](https://forums.swift.org/t/circling-back-to-with/2766 "2016-05-25T18:28:58Z")\
**Posts on this page:** 1\
**Showing post:** 81

<div class="post-metadata">

**Author:** ![ahti](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ahti/32/604_2.png) [@ahti](https://forums.swift.org/u/ahti)\
**Post date:** [March 16, 2018, 6:51am UTC](https://forums.swift.org/t/circling-back-to-with/2766/81 "2018-03-16T06:51:20Z")

</div>

If we had a bind annotation in closure parameter type lists, as @DevAndArtist suggested, we would come very close to this, and additionally could use it in a number of other ways.

Swift has precedent for making it possible to create language-style features in libraries (see @autoclosure, trailing closure syntax and custom operator support), which is, in my opinion, a good way to approach things.

Coming back to your example, this is possible today:

```swift
func using<T>(_ val: T.Type, do closure: (T.Type) -> Void) {
    closure(val)
}

enum M {
    static let a: Int = 21
    static func double(_ n: Int) -> Int { return n * 2 }
}

var mutable: Int = 0

using(M.self) {
    mutable = $0.double($0.a)
}

```

Now if using could be declared as `func using<T>(_ val: T.Type, do closure: (bind T.Type) -> Void)`, you could drop the $0, and we're quite close to your example except for the `.self` (which is something [we probably want to get rid of at some point](https://forums.swift.org/t/deferred-se-0090-remove-self-and-freely-allow-type-references-in-expressions/2781)).

---

_[View the full topic](https://forums.swift.org/t/circling-back-to-with/2766)._
