<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I also have had that kind of idea.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">You can do something like this with git, iirc they're called filters.<br><br>Pierre</div><div><br>Le 13 mars 2016 à 03:45, Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> a écrit :<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">Actually, I think this is a cool idea and I had thought along these lines too actually years ago of saving in an intermediate format. The difference that I am thinking now is that there is a Swift standard format. Where the “standard” format is what is written, but the IDE displays it in the users’ favorite format. This would not lead to diffing problems since it would be stored in Swift standard format that everyone can read and would readable and editable any text editor. So the standard might have braces at the end of the line, but when you open it in your IDE it will put them in your preferred aligned position, when it is saved, it goes back to standard format. I would not be surprised if something like this existed already (not specifically for Swift) Coming up with the standard format would largely be following most of the sample code in the Swift book so it would not be annoying to read. Just when you are hard at work on your code, you can have your favorite “view” on your code. If this component were shared it could be added to any IDE, in its read and write functions. <div class=""><br class=""></div><div class="">One tricky aspect is keeping reasonable spacing between lines. This would need to be saved in the standard format, Someone who likes things crammed together would not add spacing and their view could remove it from display, but it would do its best to preserve it in the standard file format. However if it is never inserted by the person who likes tight spacing, another person might add it in for their benefit. The tight spacing person would not see the extra lines but the standard format would keep them in there if they did not change those lines. If they did change those lines it would do its best to preserve those spaces. </div><div class=""><br class=""></div><div class="">Maybe a bit wacky but seems at least possible. </div><div class=""><br class=""></div><div class="">- Paul<br class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 12, 2016, at 6:05 PM, <a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’m not claiming that what follows is a *good* idea per se, just that it solves the problem Ted brought up…</div><div class=""><br class=""></div><div class="">What about adding an option for saving source code in a pre-parsed representation so that the displayed coding style can be decoupled from the actual source code? Off the top of my head, I think a stringified AST would work (or at least something very close to that). Is this overkill? Yes. Yes, it is. But it’d forever end the debate over which coding style the team should use... Each person could configure their IDE however they want, and it wouldn’t affect anyone else because this:</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> foo() -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int </span>{</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> bar: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> longBar: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> bar + </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">(longBar)</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">vs</div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> foo() -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> bar: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> longBar:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> bar + </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">(longBar)</span></div><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal;" class="">vs</div><div style="font-family: Helvetica;" class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""></div></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> foo</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">() -> </span><span style="color: rgb(112, 61, 170);" class="">Int</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">// Everything lined up using “proper" tabs </span><span style="font-variant-ligatures: no-common-ligatures;" class="">instead of </span>spaces</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> bar:<span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int<span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">= </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> longBar:<span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double<span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">= </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> bar + </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">(longBar)</span></div><div style="margin: 0px; line-height: normal;" class="">}</div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; line-height: normal;" class="">vs even this Python-esque insanity</div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">foo</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">()</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> bar: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> longBar: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Double</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">return</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> bar + </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(longBar)</span></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div></div></div></div></span></div></div></div><div class="">would all strictly be a local display preference, the same as your choice of font or monitor resolution.</div><div class=""><br class=""></div><div class="">As long as the format is human-readable, people could still use straight text editors if they needed to edit code that’s in this “pre-parsed” format if there isn’t a “.swift.pp”-aware editor available for their platform.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Anyway, that’s all I’ve got for this one. Pretty sure it’s too far out there, but posting it anyway just in case I’m wrong.</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div><br class=""><blockquote type="cite" class="">On Mar 11, 2016, at 4:19 PM, Ted F.A. van Gaalen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">In most IDE, like Eclipse, Netbeans etc. the formatting<br class="">is done by the IDE., It is NOT part the programming language *<br class=""><br class="">The programmer has the option to customize how<br class="">the IDE should format the source. Mostly one<br class="">will adjust this as much as possible conforming<br class="">with the company standard way of working.<br class="">But there are exceptions: more about this further down<br class="">this text.<br class=""><br class="">Formatting should not be part of the programming language itself,<br class="">except of course for obvious things, like unintentionally “glueing”<br class="">language elements together, which, of course, result<br class="">in compilation errors.<br class=""><br class="">Also, there will always be sloppy programmers,<br class="">no matter how good formatting could perhaps be,<br class="">people will always find ways to create a fantastic mess.<br class="">but to accept this or not is the responsibility of the team <br class="">he/she is in. <br class=""><br class="">So, Xcode, or for that matter any other IDE you might use, <br class="">should have under “Preferences” the option to customize <br class="">formatting behavior and also the option to disable formatting altogether .<br class="">Luckily, most IDEs provide this customization already. <br class="">Why? <br class="">Because no two humans are the same.<br class=""><br class="">Even more Important: dyslexia disorder,<br class="">which is: **<br class=""> " a general term for disorders that involve difficulty in learning to read <br class=""> or interpret words, letters, and other symbols, <br class=""> but that do not affect general intelligence.” <br class=""> "It is estimated that between 5-10% of the population has dyslexia, <br class=""> but this number can also be as high as 17%.”<br class=""><br class="">Dyslexia is nearly always present in combination with autism.<br class="">As you know, many programmers are more or less autistic. <br class="">Probably even more of them than in the average population. <br class=""><br class="">Forcing default formatting upon them (a lot of us) is obviously not a good idea! <br class=""><br class="">There are endless debates e.g. about using { } <br class="">1. <br class=""> func foo() {<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span> a = b<br class=""> }<br class=""><br class="">or 2. <br class=""><br class=""> func foo()<br class=""> {<br class=""> a = b<br class=""> }<br class=""><br class="">Personally I prefer 2. because<br class="">if I navigate through my source very quickly<br class="">my eyes don’t have to go to the end of each line<br class="">to find a starting { <br class="">resulting, at least for me, in much faster editing. <br class="">I am not very good with trailing tokens. <br class=""><br class="">also I prefer to align variables like this<br class="">var a: Double<br class="">var boat: Boat<br class="">var weather: ClimateOption<br class="">etc.<br class=""><br class="">Because I find that much easier to read<br class="">maybe autistic aspects of me.<br class="">(which btw also make communicating with other humans a bit difficult for me, you might have noticed that)<br class="">The strange thing is that, if formatted the way I prefer it,<br class="">I can read sources very fast..<br class=""><br class="">So, formatting should definitely not be<br class="">be part of the programming language<br class="">which is in essence free-format, luckily.<br class=""><br class="">Another note in this perspective is:<br class="">One should not treat programmers like little children<br class="">that need to be (over?)protected from themselves.<br class=""><br class="">One can safely assume, that, if one has made <br class="">it in being a good programmer, one obviously <br class="">possesses a reasonable intelligence level.<br class=""><br class=""><br class="">TedvG<br class=""><br class="">* (except perhaps for Python, albeit that the only requirement<br class="">with Python is indentation)<br class="">** source: Wikipedia<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>