[swift-evolution] SE-0105: Removing Where Clauses from For-In Loops
Haravikk
swift-evolution at haravikk.me
Sat Jun 25 05:15:18 CDT 2016
> On 24 Jun 2016, at 23:38, William Jon Shipley <wjs at delicious-monster.com> wrote:
>
>> On Jun 24, 2016, at 3:00 PM, Haravikk via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> for colinearSegment in remainingSegments where colinearSegment.angle.isEssentially(angle: segment.angle) { // Is parameter name even necessary?
>
> My terminology sucks because I don’t remember math terms but basically I’m trying to distinguish between angles of rays (0..<360º) and angles of lines (0..<180º). Because, like, if you have a line at 45º and another at 225º, well, they’re either collinear or parallel.
>
> So I call the variants “rayAngle:” and “infiniteLineAngle:”. Not my finest hour.
Sorry, I think I got a bit side-tracked, didn't mean to seem too critical of the name choice, my point was that the logic is actually pretty straightforward, and the line is long because of the verbose naming rather than the presence of a where clause (which could also be moved to another line as another option). As always you should use whatever names help you to understand and remember the intent of the code best, meanwhile I should actually focus on what my point was supposed to be =D
So yeah, I don't think any of the examples presented have had "too much logic" for a where clause, while more complex cases with ands, ors, etc. might become a bit less immediately readable, it's no more so than any other if-condition, and it's an issue of personal style choice regardless, rather than a fault with a where clause.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160625/65c08293/attachment.html>
More information about the swift-evolution
mailing list