# Pitch: Scoped Functions

**URL:** <https://forums.swift.org/t/pitch-scoped-functions/45486>\
**Category:** Pitches\
**Created:** [March 9, 2021, 7:33pm UTC](https://forums.swift.org/t/pitch-scoped-functions/45486 "2021-03-09T19:33:25Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [March 10, 2021, 5:56pm UTC](https://forums.swift.org/t/pitch-scoped-functions/45486/11 "2021-03-10T17:56:03Z")

</div>

This is exact. But it goes beyond the `with` statement. Besides, the implicit context is chosen by the enclosing function (here the `with` function), not by the user.

It happens that the enclosing function injects a user value as the context. This is the case of `with`:

```swift
func with<T>(_ value: T, run: @scoped (T) -> Void) { run(value) }

with("Hello") {
     print(.count) // prints "5"
     print(.lowercased()) // prints "hello"
}

```

But the enclosing function can choose to provide another context: see the database requests examples in the pitch.

---

_[View the full topic](https://forums.swift.org/t/pitch-scoped-functions/45486)._
