<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 19, 2015, at 9:21 AM, Tino Heth via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi there,</div><div class=""><br class=""></div>this idea might be quite unconventional, but it is simple and wouldn't break any existing code.<div class="">Returning void has no use beside telling "there is nothing to return" and makes it impossible to perform method chaining, which drives popular systems like iostream and LINQ (the concept was promoted by Martin Fowler as fluent interface - but wikipedia has a good explanation on this:&nbsp;<a href="https://en.wikipedia.org/wiki/Fluent_interface" class="">https://en.wikipedia.org/wiki/Fluent_interface</a>)</div><div class="">One of its most popular use cases is database access, which imho will become quite important for Swift as it might gain popularity in the server domain.</div><div class="">It is useful in other areas as well, but I'll stick to databases in an example:</div><div class=""><br class=""></div><div class="">let kids = userDatabase.select(.name).where(.age &lt; 18)</div><div class=""><br class=""></div><div class="">This is already possible in Swift today, but with a simple change, it could be much more fun:</div><div class="">I guess void is the natural choice for a default return value - what else is guaranteed to exist in a function?</div><div class="">For methods, on the other hand, there is a real object that is always available: self.</div><div class="">If self would be the default return value, we would get method chaining for free in all places where we now stuck with void - and whoever doesn't like the concept can still ignore the value as he did with ().</div><div class=""><br class=""></div><div class="">I have to admit that right now there is a proposal that wants to sanction ignoring non-void return values with warnings, which would interfere with this idea; but imho even in this case the workarounds wouldn't be that complicated.</div><div class=""><br class=""></div><div class="">So, please give feedback wether it is worth the burden of writing a official proposal or start by creating a library with the current toolset and try to prove the usefulness of fluent interfaces ;-)</div></div></div></blockquote><div><br class=""></div>In order to evaluate this more fully, I'd like to see some examples of real code that would be improved by having this facility, but in general, I'd be concerned that this proposal making mutating/side-effectful method calls look more like purely-functional ones.</div><div><br class=""></div><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""></body></html>