[swift-evolution] [Review] SE-0107: UnsafeRawPointer API (initialize:with:)

Dave Abrahams dabrahams at apple.com
Mon Jul 4 18:19:05 CDT 2016


on Sun Jul 03 2016, Andrew Trick <swift-evolution at swift.org> wrote:

>> On Jul 2, 2016, at 8:10 PM, Brent Royal-Gordon via swift-evolution
>> <swift-evolution at swift.org> wrote:
>> 
>> I have a pile of naming quibbles; rather than describe them all in
>> prose (which turned into a mess), I've annotated parts of the "Full
>> UnsafeRawPointer API" section in a gist:
>> <https://gist.github.com/brentdax/8f4ed4decafc1d18c4441092baa13cfe
>>
> <https://gist.github.com/brentdax/8f4ed4decafc1d18c4441092baa13cfe>>.
>> 
>
> Let's bikeshed this easy one now... I’m curious what others think:
>
>   // In general, I think you "initialize to" a value, not 
>   // "initialize with" a value. "with" is needlessly vacuous.
>   // 
>   // func initialize<T>(_: T.Type, with: T, count: Int = 1)
>   //   -> UnsafeMutablePointer<T>
>   func initialize<T>(_: T.Type, to: T, count: Int = 1)
>     -> UnsafeMutablePointer<T>
>
> `initialize` was recently renamed to `initialized(with:)`.
>
> commit d96b051d28b6042adcc8b8692a918abddf211aec
> Author: Dave Abrahams
> <dabrahams at apple.com>
> Date:   Tue Feb 23 15:12:24 2016 -0800
>
>     stdlib: initializePointee(_) => initialize(with:)
>
>     Tacking "Pointee" on just for unary operations (and especially
>     operations with an optional count) created inconsistency.
>
> So Swift 3 users have already migrated to this “better” name.
>
> I agree that initialize(to:) is consistent with the language we use
> for assigning values. But grammatically, I think initialize(with:)
> also makes perfect sense and is just as common.

“With” is a weak preposition with many possible interpretations, so we'd
like to avoid it.  If I used “with” where “to” would have worked, I
regret it.

> In general, if there’s controversy, I’ll stick with the existing
> conventions because there’s already enough to debate in this proposal.

Let's not compound the mistake, though, please!

-- 
-Dave



More information about the swift-evolution mailing list