[swift-evolution] SE-0105: Removing Where Clauses from For-In Loops

Xiaodi Wu xiaodi.wu at gmail.com
Fri Jun 24 16:53:56 CDT 2016


On Fri, Jun 24, 2016 at 4:33 PM, Erica Sadun <erica at ericasadun.com> wrote:

>
> On Jun 24, 2016, at 12:04 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
> On Fri, Jun 24, 2016 at 12:59 AM, William Shipley via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> Here are some of my real-world examples:
>>
>>         for modelUUIDAndInterfaceElement in modelUUIDsToInterfaceElements
>> where !usedInterfaceElements.contains(modelUUIDAndInterfaceElement.1) {
>>
>
> Not a practitioner of 80-character line limits, I take it?
>
>
> 80-character line limits aren't why these examples  are problematic for me.
>

Sorry, I'm going to selfishly interject here to clarify what I meant by
that question to Wil.

I was not implying that his code was problematic for me--far be it from me
to critique Wil's code or style, a task for which I'm not qualified. And
I'm truly appreciative that Wil was willing to share his code so that we
could learn about the use of `where` in closed-source contexts.

The point I was trying to bring up was that a purported advantage of
keeping `where` is moot for those who *do* observe line limits, which
includes the Swift stdlib itself as well as (IIUC) house style at Google,
Microsoft, etc.


> Other than a few positive examples like this wall.anchors one,
>
>          for anchor in wall.anchors where boundsRect.contains(anchor.
> origin) {
>
>
> most of these read as if there is too much logic stuffed into a single
> line:
>
> for otherWall: Wall in self where otherWall != wall && !removedWalls.
>> contains(otherWall) {
>>
>>
>>         for otherPieceOfFurnitureNode in
>> localFurnitureModelUUIDsToInterfaceElements!.values where
>> otherPieceOfFurnitureNode !== pieceOfFurnitureNode {
>>
>>
>>         for lineSegmentObject in wallRelatedLineSegments where
>> remainingLineSegments.contains(lineSegmentObject) {
>>
>>
>>         for colinearLineSegmentObject in remainingLineSegments where
>> colinearLineSegmentObject.angle.isEssentially(infiniteLineAngle:
>> lineSegmentObject.angle) {
>>
>>>>
>>
> -- E
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160624/3e2816a4/attachment.html>


More information about the swift-evolution mailing list