<div dir="ltr">Very strong -1 to implicit 'with'. Javascript tried this and it was a disaster, and eventually banned in strict mode. It tends to make compilation and optimization of a variable within a 'with' block impossible, as it could refer to the fields of any object, or even a method call behind protocol accessors. It also made it very difficult to understand code, as you had to inspect values with a debugger before you could grok the meaning of a simple variable reference.<div><br></div><div>Explicit 'with' is intriguing - it avoids a number of these pitfalls. But the syntax suggested conflicts with that used for enums and static member access. Right now, '.foo' is shorthand for 'Type.foo', where Type is the inferred type of the expression. With the proposed syntax, would it instead refer to the member of the 'with' referend? From the proposed example, it looks like it:</div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">with textLabel{</span></div><div><span style="font-size:12.8px"> .textAlignment</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">=</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">.Left</span></div><div><span style="font-size:12.8px"> .textColor</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">= UIColor</span><span style="font-size:12.8px">.darkTextColor</span><span style="font-size:12.8px">()</span></div><div><span style="font-size:12.8px"> .font</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">= UIFont</span><span style="font-size:12.8px">.systemFontOfSize</span><span style="font-size:12.8px">(</span><span style="font-size:12.8px">15</span><span style="font-size:12.8px">)</span></div><div><span style="font-size:12.8px">}</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Note that UIColor and UIFont have to be explicit here. That's not really an improvement in verbosity on how you'd write it now:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">textLabel.textAlignment = .Left</span></div><div><span style="font-size:12.8px">textLabel.textColor = .darkTextColor()</span></div><div><span style="font-size:12.8px">textLabel.font = .systemFontOfSize(15)</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Ultimately, I think I'm +1 for the library solution, where NSObject (is there any way to extend all *Swift* objects, so they don't need the Objective-C runtime?) gets a new method:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">let textLabel = UILabel().with {</span></div><div><span style="font-size:12.8px"> $0.textAlignment = .Left</span></div><div><span style="font-size:12.8px"> $0.textColor = .darkTextColor()</span></div><div><span style="font-size:12.8px"> $0.font = .systemFontOfSize(15)</span></div><div><span style="font-size:12.8px">}</span></div><div><div class="gmail_extra"><br></div><div class="gmail_extra">Also, on a philosophical note:</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 13, 2016 at 9:54 AM, Vladimir.S via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br>
On 13.04.2016 18:09, Radosław Pietruszewski wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I’m -1, at least in the foreseeable future. I do agree that this is a<br>
useful construct, but if I can do it in library code, paying only a small<br>
price for this, I’d prefer Swift to grow better in places that a library<br>
*can’t* fix.<br>
</blockquote>
<br></span>
Well, there a lot of things that *your personal* library can fix for you.<br>
Should we stop improve the language and start to write just personal libs with improvements?<br>
<div class=""><div class="h5"><br></div></div></blockquote><div><br></div><div>Yes, absolutely. At least until your personal lib has gotten some widespread adoption and people have had a chance to hack with it for a while. Perhaps we need better tools for sharing, distributing, and integrating utility libs (SwiftPM is coming!), but I feel strongly that this is a better development methodology than including every imaginable feature in the language itself.</div><div><br></div><div>The problem is that nearly all language features have unintended corner cases, unintended consequences on development, and impedance mismatches with existing language features. You can't predict what these will be until you've written a bunch of *actual code* using them, in the target language. When it's your personal lib, you can iterate on this nearly instantaneously. When it's a language spec, every change requires long consensus discussions, and you can't back out previous changes that people are relying on.</div></div></div></div></div>