> On Dec 12, 2016, at 6:30 PM, Ben Cohen <[email protected]> wrote:
> 
> 
>> On Dec 12, 2016, at 1:32 PM, Andrew Trick <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>>> 
>>> On Dec 7, 2016, at 10:07 PM, Douglas Gregor via swift-evolution 
>>> <[email protected] <mailto:[email protected]>> wrote:
>>> 
>>> Hello Swift community,
>>> 
>>> The review of SE-0147 "Move UnsafeMutablePointer.initialize(from:) to 
>>> UnsafeMutableBufferPointer" begins now and runs through December 12, 2016. 
>>> The proposal is available here:
>>> 
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0147-move-unsafe-initialize-from.md
>>>  
>>> <https://github.com/apple/swift-evolution/blob/master/proposals/0147-move-unsafe-initialize-from.md>
>>> Reviews are an important part of the Swift evolution process. All reviews 
>>> should be sent to the swift-evolution mailing list at
>>> 
>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>> or, if you would like to keep your feedback private, directly to the review 
>>> manager. When replying, please try to keep the proposal link at the top of 
>>> the message:
>>> 
>>> Proposal link:
>>> 
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0147-move-unsafe-initialize-from.md
>>>  
>>> <https://github.com/apple/swift-evolution/blob/master/proposals/0147-move-unsafe-initialize-from.md>
>> For UnsafeMutableRawBufferPointer.initializeMemory:
>> 
>> We have this doc comment:
>> 
>>   /// Returns an iterator to any elements of `source` that didn't fit in the 
>>   /// buffer, and an index into the buffer one past the last byte written.
>> 
>> Which is consistent with the PR https://github.com/apple/swift/pull/5718 
>> <https://github.com/apple/swift/pull/5718>
>> 
>> + public func initializeMemory<S: Sequence>(
>> +    as: S.Iterator.Element.Type, from source: S
>> +  ) -> (unwritten: S.Iterator, initializedUpTo: Index) {
>> 
>> However, the proposal reads:
>> 
>> public func initializeMemory<S: Sequence>(
>>      as: S.Iterator.Element.Type, from source: S
>>   ) -> (unwritten: S.Iterator, initialized: 
>> UnsafeMutableBufferPointer<S.Iterator.Element>)
>> 
>> Which API did we end up deciding on?
>> 
>> (unwritten:, initialized:) makes sense to me, but I can’t remember if we 
>> ditched that approach for some reason (e.g. consistency with 
>> UnsafeMutableBufferPointer).
>> 
>> -Andy
> 
> The proposed API in the proposal is right, the comment above it should have 
> been updated. The intention is for the raw buffer version to return an 
> initialized typed buffer not an index into the raw buffer. While this means 
> it’s inconsistent with the typed equivalent, an index into the raw buffer 
> isn’t all that useful as usually you want to operate on typed values after 
> you’ve initialized them, and the calculation to get to the raw buffer index 
> from the typed buffer if you need it is easy i.e. initialized.count * the 
> stride of the type.
> 
> (I haven’t yet updated the PR to reflect this change yet either, was waiting 
> to see if there was more feedback first to incorporate)

That’s good. Those are the reasons the proposed API makes more sense to me too.

-Andy

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to