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

Sean Heber sean at fifthace.com
Fri Jun 24 13:56:41 CDT 2016

> On Jun 24, 2016, at 1:30 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> On Fri, Jun 24, 2016 at 6:37 AM, William Shipley <wjs at mac.com> wrote:
> On Jun 23, 2016, at 11:04 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> Not a practitioner of 80-character line limits, I take it?
> I don’t understand why anyone wouldn’t just let Xcode do the wrapping for most cases. I’ll add newlines if I think it adds to clarity, but in general I don’t want to code like i’m still on a Wyse WY-50.
> Of course, to each their own style--I certainly wouldn't want Swift to force everyone to write lines of certain lengths. But 80-character lines is a common style, and I would say that a corollary of "to each their own" is that Swift's grammar should be usable and useful whether or not you adhere to such style choices.

I honestly don’t believe that this a common style in the Cocoa community. I’m not a member of the “old guard” having only come into this world 10 years ago with the iPhone, but just take a look at this delegate method in Objective-C:

- (void)locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error;

That’s well over 80 characters all by itself. This fits on my screen in a single line - and I work on a 15” MBP with room for my dock always visible on the side along with Xcode’s sidebar open! On a typical desktop-sized screen, 80-col lines must be comically short.

I don’t know why it should be assumed that people are adhering to a so-called standard that dates back to terminal screens that didn’t have color.

> If the chief advantage of `where` is that it (quoting someone above) allows one to "understand as much as possible about the control flow of the loop from a single line of code," then we ought perhaps to question its appropriateness when the majority of its benefits [by which I mean, based on your examples and Sean's, more than half of the instances in which it is used] cannot be realized in a very common coding style.

Again, I dispute the idea (having no data but my own :P) that 80-col limits are common in this community.


More information about the swift-evolution mailing list