I created a proposal: https://github.com/apple/swift-evolution/pull/545 <https://github.com/apple/swift-evolution/pull/545>
> On Oct 11, 2016, at 11:32 PM, Dave Abrahams via swift-evolution > <[email protected]> wrote: > > > on Tue Oct 11 2016, Károly Lőrentey <[email protected] > <mailto:[email protected]>> wrote: > >> +1 >> >> ManagedBuffer has been really useful a couple of times, but I never >> found a use for ManagedBufferPointer. I can’t even say I’m entirely >> sure what need it was originally designed to fulfill. > > The real need is/was to be able to do the same kind of storage > management in classes not derived from ManagedBuffer. This can be > important for bridging, where the buffers of various native swift > containers need to be derived from, e.g., NSString or NSArray. That is, > however, an extremely stdlib-specifc need. > > >>> On 2016-10-11, at 00:12, Erik Eckstein via swift-evolution >> <[email protected]> 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 >>> [email protected] >>> https://lists.swift.org/mailman/listinfo/swift-evolution >> >> _______________________________________________ >> swift-evolution mailing list >> [email protected] <mailto:[email protected]> >> https://lists.swift.org/mailman/listinfo/swift-evolution >> <https://lists.swift.org/mailman/listinfo/swift-evolution> >> > > -- > -Dave > > _______________________________________________ > swift-evolution mailing list > [email protected] <mailto:[email protected]> > https://lists.swift.org/mailman/listinfo/swift-evolution > <https://lists.swift.org/mailman/listinfo/swift-evolution>
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
