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

Andrew Trick atrick at apple.com
Sun Jul 3 03:18:42 CDT 2016

> 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.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160703/229a9541/attachment.html>

More information about the swift-evolution mailing list