[swift-evolution] [Pitch] deprecating ManagedBufferPointer
Robert Widmann
devteam.codafi at gmail.com
Tue Oct 11 14:43:43 CDT 2016
+1. I haven’t found use for it, and I don’t think there is one outside of stdlib.
~Robert Widmann
> On Oct 10, 2016, at 6:12 PM, Erik Eckstein via swift-evolution <swift-evolution at swift.org> wrote:
>
> The purpose of ManagedBufferPointer is to create a buffer with a custom class-metadata to be able to implement a custom deinit (e.g. to destroy the tail allocated elements).
> It was used in Array (before I replaced it with the new tail-allocated-array-built-ins). But now it’s not used anymore in the standard library.
>
> As a replacement for ManagedBufferPointer one can just derive a class from ManagedBuffer and implement the deinit in the derived class.
>
> final class MyBuffer : ManagedBuffer<MyHeader, MyElements> {
> deinit {
> // do whatever needs to be done
> }
> }
>
> // creating MyBuffer:
> let b = MyBuffer.create(minimumCapacity: 27, makingHeaderWith: { myb in return MyHeader(...) })
>
> IMO ManagedBuffer is much cleaner than ManagedBufferPointer (it doesn’t need this custom bufferClass to be passed to the constructor). Also ManagedBufferPointer doesn’t use SIL tail-allocated arrays internally. Although this is not something visible to the programmer, it makes life easier for the compiler.
>
> So I suggest that we deprecate ManagedBufferPointer.
>
> Erik
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161011/ead89e3c/attachment.html>
More information about the swift-evolution
mailing list