<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="">
&gt; Hello everyone!<br class="">&gt; <br class="">&gt; I was unable to make the kick-off meeting for the HTTP sub-team, but I looked over themeeting notes(<a href="https://docs.google.com/document/d/1SWK0qBDi-9DeLJwHlcXcPU7h22JU-DWW8HTVuHbTQiw/edit" class="">https://docs.google.com/document/d/1SWK0qBDi-9DeLJwHlcXcPU7h22JU-DWW8HTVuHbTQiw/edit</a>)and found some topics that I think could use some more on-the-record discussion.<br class="">&gt; <br class="">&gt; A few questions that I wanted to raise:<br class="">&gt; <br class="">&gt; 1. Do we want to use concrete types or protocols for Request/Response?<br class="">&gt; 2. If we use concrete types, do we want value or reference semantics?<br class="">&gt; 3. When is it more convenient to have reference semantics?<br class="">&gt; 4. Are there problems that can't be solved with value semantics?<br class="">&gt; <br class="">&gt; I would like to avoid bike-shedding, and I think this can be done by providing real examples rather than just talking about the pros and cons.<br class="">&gt; --<br class="">&gt; Dan Appel<br class="">&gt; <br class="">&gt; <br class="">&gt;<span class="Apple-converted-space">&nbsp;</span>

<div class=""><span class="Apple-converted-space"><br class=""></span></div><div class=""><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">My own responses:</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&gt;1. Do we want to use concrete types or protocols for Request/Response?</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">When working on&nbsp;<a href="https://github.com/open-swift" class=""><span style="color: rgb(228, 175, 9);" class="">Open Swift</span></a>, this was a hot topic since we believed that it would be unsafe to have a protocol that would allow both value and reference types. We arrived upon the `{Request|Response}Representable` pattern which worked but was a bit of a mess. Because of this, I would prefer concrete Request/Response types.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&gt;2. If we use concrete types, do we want value or reference semantics?</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">What I think makes this easier is that the "big four" have each taken a slightly different approach that can be used as a reference.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><span style="text-decoration: underline ; color: #e4af09" class=""><a href="https://github.com/Zewo/Zewo/blob/master/Modules/HTTP/Sources/HTTP/Message/Request.swift#L3" class="">Zewo</a></span>&nbsp;-&nbsp;struct, value semantics</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><span style="text-decoration: underline ; color: #e4af09" class=""><a href="https://github.com/vapor/engine/blob/master/Sources/HTTP/Models/Request/Request.swift#L4" class="">Vapor</a></span>&nbsp;-&nbsp;closed class, reference semantics</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><span style="text-decoration: underline ; color: #e4af09" class=""><a href="https://github.com/IBM-Swift/Kitura/blob/master/Sources/Kitura/RouterRequest.swift#L26" class="">Kitura</a></span>&nbsp;- closed class&nbsp;+ has-a pattern, reference semantics</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><span style="text-decoration: underline ; color: #e4af09" class=""><a href="https://github.com/PerfectlySoft/Perfect-HTTP/blob/master/Sources/HTTPRequest.swift#L25" class="">Perfect</a></span>&nbsp;- class protocol, reference semantics</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Zewo is the outlier here, but I would like to note as a contributor to Zewo that we have not ran into situations where value semantics create an impassable roadblock.&nbsp;</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">To me, it makes sense to pass them around as values since they don't have any logic of their own. Requests/Responses can't send themselves, they can only read and modified. It also gives me as a user more safety to pass them around since I know that they won't be modified implicitly.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Take the following pseudo-code as an example:</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">HTTPServer.onRequest&nbsp;{ request in</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&nbsp; &nbsp; print(request.sourceIp)</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&nbsp; &nbsp; HTTPClient.send(request)</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&nbsp; &nbsp; print(request.sourceIp)</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">}</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">With reference semantics, there is no guarantee that sourceIp will be the same before and after sending off the request. After all, it <i class="">could</i> make sense for the HTTPClient to modify the sourceIp before sending off the request. This of course a contrived example, but the point stands.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Anyway, I think it would be great if we could have people talk about their own experiences.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&gt;3. When is it more convenient to have reference semantics?</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">In the middleware chain architecture that we decided on in Zewo (the other ones have something similar), it can be convenient to modify requests in the responder and have that reflect in the middleware. I think this problem is best solved with `inout` parameters rather than reference types, but that is my personal opinion.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">&gt;4. Are there problems that can't be solved with value semantics?</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">I haven't found one that we can't solve, but I'm sure others can bring something interesting to the table.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class="">--</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Dan Appel</div></div></body></html>