[swift-evolution] [Pitch] Eliminate `ManagedProtoBuffer`

Brent Royal-Gordon brent at architechies.com
Tue Jul 19 01:49:06 CDT 2016


> On Jul 18, 2016, at 10:05 PM, Charlie Monroe <charlie at charliemonroe.net> wrote:
> 
>> I haven't used `ManagedBuffer`, but would it make sense to change the signature of `initialHeader` to `@noescape (elements: UnsafeMutablePointer<Element>, capacity: Int) -> Header` and then effectively run it inside a `withUnsafeMutablePointerToElements()` call? That would prevent access to the uninitialized `header` field while also allowing us to eliminate the `ManagedProtoBuffer` type.
> 
> Wouldn't this disallow access to the capacity field? That's as well defined on ManagedProtoBuffer and AFAIK can be accessed during the initialization.

Yes, which is why I suggested it should be passed in to the `initialHeader` closure too. (It's read-only anyway, so there's no loss of capability.) What it *does* prevent access to is `withUnsafeMutablePointerToHeader`, but I'm not sure how that method is supposed to work before the header's been initialized anyway.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list