# \[Pitch\] Restore count(where:) from SE-0220

**URL:** <https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859>\
**Category:** Pitches\
**Created:** [June 27, 2023, 7:57pm UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859 "2023-06-27T19:57:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![soroush](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/soroush/32/859_2.png) [@soroush](https://forums.swift.org/u/soroush)\
**Post date:** [June 27, 2023, 7:57pm UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/1 "2023-06-27T19:57:48Z")

</div>

Hi everyone,

After @hborla's work on operator typechecking, I think it's a good time to revisit my old proposal, [SE-0220](https://github.com/apple/swift-evolution/blob/main/proposals/0220-count-where.md), for inclusion into the standard library.

For those who aren't aware of the backstory, this proposal was [pitched](https://forums.swift.org/t/count-where-on-sequence/11186/41), [reviewed](https://forums.swift.org/t/se-0220-count-where/15048), [accepted](https://forums.swift.org/t/se-0220-count-where/15048/21), and had its [implementation merged](https://github.com/apple/swift/pull/16099) a few years ago. However, it caused issues with typechecking (namely, `.count` the integer and `.count` as a reference to the function `.count(where:)` were getting mixed up and causing bigtime slowdowns when figuring out which version of operators to use), and it was reverted. Holly [fixed the typechecking issue a little while ago](https://github.com/apple/swift/pull/39390), and I'd love to see if we can reintroduce this functionality.

---

<div class="post-metadata">

**Author:** ![harlanhaskins](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/harlanhaskins/32/333_2.png) [@harlanhaskins](https://forums.swift.org/u/harlanhaskins)\
**Post date:** [June 27, 2023, 8:01pm UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/2 "2023-06-27T20:01:10Z")

</div>

This is great!

This also seems like a great candidate for a `@backDeployed(before: macOS XXX)`, since its implementation doesn't require any special syntax or functions.

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [June 27, 2023, 8:03pm UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/3 "2023-06-27T20:03:44Z")

</div>

Unless I'm mistaken, this method could be always-emit-into-client. Is the standard library now using `@backDeployed` exclusively instead now?

---

<div class="post-metadata">

**Author:** ![harlanhaskins](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/harlanhaskins/32/333_2.png) [@harlanhaskins](https://forums.swift.org/u/harlanhaskins)\
**Post date:** [June 27, 2023, 8:07pm UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/4 "2023-06-27T20:07:12Z")

</div>

Ah, I don't know from a policy perspective. `@_alwaysEmitIntoClient` is fine too.

---

<div class="post-metadata">

**Author:** ![lorentey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lorentey/32/1299_2.png) [@lorentey](https://forums.swift.org/u/lorentey)\
**Post date:** [June 28, 2023, 9:18am UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/5 "2023-06-28T09:18:27Z")

</div>

I think `@backDeployed` is preferable to an underscored attribute like @\_aeic, unless we wouldn’t want to introduce ABI for the new method (which isn’t the case here), or unless we found an issue with `@backDeployed` (say, if it prevented specialization or some other important optimization, or if it didn’t support the customary SwiftStdlib availability aliases).

I believe the attribute was carefully designed to avoid such problems, but we haven’t tried applying it for the stdlib’s existing backdeployable API surface, so there may be some unforeseen interactions that are still lurking there. If so, it’s time to find them, anyway!

---

<div class="post-metadata">

**Author:** ![JetForMe](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jetforme/32/482_2.png) [@JetForMe](https://forums.swift.org/u/JetForMe)\
**Post date:** [July 10, 2023, 11:57pm UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/6 "2023-07-10T23:57:30Z")

</div>

Sorry to hijack this thread, but is there an article or document somewhere that comprehensively discusses `@backDeployed` and `@_alwaysEmitIntoClient` and friends?

---

<div class="post-metadata">

**Author:** ![David\_Smith](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/david_smith/32/37508_2.png) [@David\_Smith](https://forums.swift.org/u/David_Smith)\
**Post date:** [July 11, 2023, 12:16am UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/7 "2023-07-11T00:16:43Z")

</div>

[https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md](https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md) for the former

---

<div class="post-metadata">

**Author:** ![Zollerboy1](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/zollerboy1/32/12997_2.png) [@Zollerboy1](https://forums.swift.org/u/Zollerboy1)\
**Post date:** [July 11, 2023, 1:29am UTC](https://forums.swift.org/t/pitch-restore-count-where-from-se-0220/65859/8 "2023-07-11T01:29:01Z")

</div>

There isn't too much written about `@_alwaysEmitIntoClient` here, but it's at least something: [https://github.com/apple/swift/blob/main/docs/ReferenceGuides/UnderscoredAttributes.md#\_alwaysemitintoclient](https://github.com/apple/swift/blob/main/docs/ReferenceGuides/UnderscoredAttributes.md#_alwaysemitintoclient)
