# \[Pitch\] Result builder scoped unqualified lookup

**URL:** <https://forums.swift.org/t/pitch-result-builder-scoped-unqualified-lookup/62190>\
**Category:** Pitches\
**Tags:** result-builder\
**Created:** [December 22, 2022, 8:00pm UTC](https://forums.swift.org/t/pitch-result-builder-scoped-unqualified-lookup/62190 "2022-12-22T20:00:06Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![filip-sakel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/filip-sakel/32/8697_2.png) [@filip-sakel](https://forums.swift.org/u/filip-sakel)\
**Post date:** [December 24, 2022, 9:12am UTC](https://forums.swift.org/t/pitch-result-builder-scoped-unqualified-lookup/62190/14 "2022-12-24T09:12:11Z")

</div>

> [@codename](#):
>
> the result builder could have a `Namespace` (pseudo?) associated type sort of thing, defaulted to itself.

I prefer this to an attribute. Also, even with this approach, users can combine multiple namespaces, by creating protocols for each one and then sharing them.  
E.g.

```swift
protocol HTMLDiv {}
extension HTMLDiv {
  static func div(@HTMLBuilder _ builder: () -> HTMLValue) -> HTMLValue { … }
} 

protocol HTMLHeaders {}
extension HTMLHeaders {
  static func h1(_ text: String) -> HTMLValue { … }
  // h2, h3, etc.
} 

@resultBuilder enum CustomHTMLBuilder {
  enum Namespace: HTMLDiv, HTMLHeaders {}
}

```

> [@Jumhyn](#):
>
> If not, is there a more general language feature looming behind this extension of result builders?

This reminds me of the [SwiftPredicates](https://forums.swift.org/t/pitch-swift-predicates/62000) pitch, where one of the main reasons for using macros is that operator overloading is too slow. Maybe with scoped unqualified lookup, the macro could be replaced with standard, well understood features for adding custom operators.

> [@angela-laar](#):
>
> If a declaration of that component name is not found, lookup will fall back to lexical lookup.

How will users opt out of name lookup in the result-builder namespace? Also would a type in the namespace be prioritized over a module name, e.g. ThisModule.div or Swift.OneOrMore?

---

_[View the full topic](https://forums.swift.org/t/pitch-result-builder-scoped-unqualified-lookup/62190)._
