SE-0322: Temporary Uninitialized Buffers

+1, yes it is, yes it does. This is an important bit of missing functionality for working with imported APIs and otherwise for low level fiddling with things. More detailed thoughts/comments/questions below.

I've worked with C and C++ quite a bit, but I think that this approach fits well with existing Swift patterns. I read the proposal, but not the pitch phase or other discussions.


A nit about the proposal is "We could optionally provide". For clarity, it helps if the proposal would state one clear opinion about what is being proposed, instead of offering up multiple design points. Alternates can be discussed in the "alternatives considered" section.

My opinion is that we should take the scalar version of this as well. Arrays are important, but scalar aggregates are important too, and in the scalar case you want to get a UnsafeMutablePointer (not a buffer pointer) as you've written.


With respect to the new builtin, does this generate the llvm.lifetime.start/end intrinsics?


Is this enough to provide a new Array initializer that puts its elements on-the-stack ala llvm::SmallVector?


I think we should eventually discuss how we're going to un-pyramid-of-doom the with style methods, but that is definitely orthogonal to this proposal.

-Chris

9 Likes