<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="">The reason why `ManagedProtoBuffer` (the base class of `ManagedBuffer`) exists is to give the users an extra bit&nbsp;of type safety inside of the closure `initialHeader` passed to `ManagedBuffer.create()`.<div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">public class ManagedBuffer&lt;Header, Element&gt;</font></div><div class=""><font face="Menlo" class="">&nbsp; : ManagedProtoBuffer&lt;Header, Element&gt; {</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">&nbsp; /// Create a new instance of the most-derived class, calling</font></div><div class=""><font face="Menlo" class="">&nbsp; /// `initialHeader` on the partially-constructed object to</font></div><div class=""><font face="Menlo" class="">&nbsp; /// generate an initial `Header`.</font></div><div class=""><font face="Menlo" class="">&nbsp; public final class func create(</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; minimumCapacity: Int,</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; initialHeader: @noescape (ManagedProtoBuffer&lt;Header, Element&gt;) throws -&gt; Header</font></div><div class=""><font face="Menlo" class="">&nbsp; ) rethrows -&gt; ManagedBuffer&lt;Header, Element&gt; {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; // ...</font></div><div class=""><font face="Menlo" class="">&nbsp; }</font></div></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class="">This closure receives the `ManagedBuffer` instance and returns the initial&nbsp;value that is stored in the buffer (the header part of the buffer). &nbsp;We are&nbsp;passing the `ManagedBuffer` as `ManagedProtoBuffer` to prevent the closure&nbsp;from reading the uninitialized `value` property. This property is defined in `ManagedBuffer` but not in `ManagedProtoBuffer`.</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; public final var header: Header {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; // ...</font></div></div><div class=""><font face="Menlo" class="">&nbsp; }</font></div><div class=""><br class=""></div><div class="">This extra bit of&nbsp;safety requires the existence of `ManagedProtoBuffer`, which complicates the API.</div><div class="">The name may also lead to some confusion with Google's Protocol Buffers project.</div><div class=""><br class=""></div><div class="">This proposal suggests removing `ManagedProtoBuffer` in order to simplify the API.</div><div class="">It means that &nbsp;`ManagedBuffer` would not be derived from `ManagedProtoBuffer` and all methods from `ManagedProtoBuffer` would be moved to `ManagedBuffer`.</div><div class="">The closure `initialHeader` would receive a &nbsp;`ManagedBuffer` instead of a `ManagedProtoBuffer`.</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font face="Menlo" class="">public class ManagedBuffer&lt;Header, Element&gt;</font><span style="font-family: Menlo;" class="">&nbsp;{</span></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">&nbsp; /// Create a new instance of the most-derived class, calling</font></div><div class=""><font face="Menlo" class="">&nbsp; /// `initialHeader` on the partially-constructed object to</font></div><div class=""><font face="Menlo" class="">&nbsp; /// generate an initial `Header`.</font></div><div class=""><font face="Menlo" class="">&nbsp; public final class func create(</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; minimumCapacity: Int,</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; initialHeader: @noescape (ManagedBuffer&lt;Header, Element&gt;) throws -&gt; Header</font></div><div class=""><font face="Menlo" class="">&nbsp; ) rethrows -&gt; ManagedBuffer&lt;Header, Element&gt; {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; // ...</font></div><div class=""><font face="Menlo" class="">&nbsp; }</font></div></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div></div><div class=""><div class="">Also `ManagedBufferPointer`'s init function (the second occurrence of &nbsp;`ManagedProtoBuffer`) would receive a &nbsp;`ManagedBuffer` instead of a `ManagedProtoBuffer`:</div></div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; /// Manage the given `buffer`.</font></div><div class=""><font face="Menlo" class="">&nbsp; ///</font></div><div class=""><font face="Menlo" class="">&nbsp; /// - Note: It is an error to use the `header` property of the resulting</font></div><div class=""><font face="Menlo" class="">&nbsp; /// &nbsp; instance unless it has been initialized.</font></div><div class=""><font face="Menlo" class="">&nbsp; internal init(_ buffer: ManagedBuffer&lt;Header, Element&gt;) {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; _nativeBuffer = Builtin.castToNativeObject(buffer)</font></div><div class=""><font face="Menlo" class="">&nbsp; }</font></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Motivation
==========</pre></div><div class="">The removal of `ManagedProtoBuffer` would simplify the API and avoids confusion with Google's Protocol Buffers.</div><div class=""><br class=""></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Alternatives
============</pre></div><div class="">*) Leave as is.</div><div class="">*) Rename the class to avoid the "confusion"-problem.</div><div class=""><br class=""></div></body></html>