The requested revisions to SE-0263 have been made to the proposal:
Please see the updated review proposal:
The review will resume and continue until October 14 to allow the community to have a chance to discuss the API change.
The requested revisions to SE-0263 have been made to the proposal:
Please see the updated review proposal:
The review will resume and continue until October 14 to allow the community to have a chance to discuss the API change.
+1. This addresses my concerns from the previous pitch thread, and I am now happy with this proposal. Thanks so much @David_Smith, and everyone who helped on the original review thread.
+1
This nit remains from the previous version of the proposal:
The new initializer takes a closure that operates on an
UnsafeMutableBufferPointer
and aninout
count of initialized elements.
No it doesn’t.
Also, I’d very much appreciate if we could back-deploy this API to older versions of the standard library. Doing so would result in cleaner, less spaghetti-like code for users of this initialiser. iOS 13/Catalina just shipped, so it’ll be years before we can raise our minimum deployment targets above Swift 5.1.
As for that back-deployed version, I think we probably can do better than what the user would do manually. Even if for some reason we can't provide the closure with a pointer to _StringGuts
's internal buffer, we could do something like:
Int/Float
already do and give a pointer to that.Worst case, we can just allocate the memory and copy it in to the String buffer, like the user would have to do themselves, but with better usability because on newer systems it would just be faster.
+1, definitely needed
I said, the previous review thread,
and I guess you chose the former. I'm glad that the label is now consistent and see no other issues here. Thanks for everyone's work on this.
@David_Smith: was this missed in the update?
Looks like it, which is odd because I definitely remember making that edit; I suppose the change must not have saved before I committed. In the interests of expediency, I redid the change and pushed it directly to the s-e repo. The new description is
The new initializer takes a closure that operates on an
UnsafeMutableBufferPointer
referencing the uninitialized contents of the newly created
String's storage, and returns a count of initialized elements or 0.
(edit)
Thanks for catching the oversight, @Karl !