<div dir="ltr"><div>I don’t really have a strong preference between either `<span style="font-family:monospace,monospace">repeating:</span>` or `<span style="font-family:monospace,monospace">value:</span>`, this all kind of seems like bikeshedding to me tbh. If I had to pick one, I’d pick `<span style="font-family:monospace,monospace">repeating:</span>` though because that’s what `<span style="font-family:monospace,monospace">Array.init(repeating:count:)</span>` uses, even if it makes a lot of calls sound a little weird. `<span style="font-family:monospace,monospace">ptr.initialize(repeating: value)</span>` <a href="http://www.macromeme.com/cat/boneless-chicken-eggs.jpg">isn’t wrong</a>, it just happens to be repeated once.<br><br></div>More important I think is the immutable buffer pointer overloads for `<span style="font-family:monospace,monospace">initialize(from:)</span>` and `<span style="font-family:monospace,monospace">assign(from:)</span>`. Currently the compiler doesn’t recognize `<span style="font-family:monospace,monospace">UnsafeBufferPointer</span>` as a subtype of `<span style="font-family:monospace,monospace">UnsafeMutableBufferPointer</span>`. Idk if it’s worth waiting for this to get added to the compiler, or just cover it in the standard library.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 19, 2017 at 2:47 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Jul 19, 2017, at 11:13 AM, Taylor Swift <<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>> wrote:</div><br class="m_-4909203032506144131Apple-interchange-newline"><div><div dir="ltr">What about `<span style="font-family:monospace,monospace">value:</span>`?<br><br><span class="m_-4909203032506144131gmail-im">`<span style="font-family:monospace,monospace">ptr.initialize(value: value)</span>`<br></span><span class="m_-4909203032506144131gmail-im">`<span style="font-family:monospace,monospace">ptr.initialize(</span></span><span class="m_-4909203032506144131gmail-im"><span style="font-family:monospace,monospace"><span class="m_-4909203032506144131gmail-im"><span style="font-family:monospace,monospace">value</span></span>: value, count: 13)</span>`<br></span><span class="m_-4909203032506144131gmail-im">`<span style="font-family:monospace,monospace">ptr.initialize(as: UInt16.self, </span></span><span class="m_-4909203032506144131gmail-im"><span style="font-family:monospace,monospace"><span class="m_-4909203032506144131gmail-im"><span style="font-family:monospace,monospace">at: 0, value</span></span>: value, count: 13)</span>`</span></div></div></blockquote><div><br></div></span><div>Works for me if it’s reasonably consistent with the rest of the stdlib. I don’t know why `value` was avoided in the first place.</div>-Andy</div><div><div class="h5"><div><br><blockquote type="cite"><div><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 19, 2017 at 12:01 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Jul 18, 2017, at 9:42 PM, Taylor Swift <<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>> wrote:</div><br class="m_-4909203032506144131m_1503010331774072828Apple-interchange-newline"><div><div dir="ltr"><div>How do we feel about changing the label to `repeated:`, even in cases where `count:` is 1?<br><br></div><div>This would mean that calls would read like this: `<span style="font-family:monospace,monospace">ptr.initialize(repeated: value)</span>`<br></div></div></div></blockquote><div><br></div></span>Right. Given the default `count` of 1, it’s probably best to stick with `to: value`.</div><div>-Andy<div><div class="m_-4909203032506144131h5"><br><blockquote type="cite"><div><div dir="ltr"><div><br></div>A grep through the stdlib shows that this is by far the most common use case:<br><br><font size="1"><span style="font-family:monospace,monospace">swift-source/swift$ grep initialize\(to: . -r<br>./stdlib/private/SwiftPrivateP<wbr>threadExtras/SwiftPrivatePthre<wbr>adExtras.swift: result.initialize(to: block(arg))<br>./stdlib/private/StdlibUnittes<wbr>t/OpaqueIdentityFunctions.<wbr>swift: ptr.initialize(to: x)<br>./stdlib/private/SwiftReflecti<wbr>onTest/SwiftReflectionTest.<wbr>swift: anyPointer.initialize(to: any)<br>./stdlib/private/SwiftReflecti<wbr>onTest/SwiftReflectionTest.<wbr>swift: fn.initialize(to: ThickFunction0(function: function))<br>./stdlib/private/SwiftReflecti<wbr>onTest/SwiftReflectionTest.<wbr>swift: fn.initialize(to: ThickFunction1(function: function))<br>./stdlib/private/SwiftReflecti<wbr>onTest/SwiftReflectionTest.<wbr>swift: fn.initialize(to: ThickFunction2(function: function))<br>./stdlib/private/SwiftReflecti<wbr>onTest/SwiftReflectionTest.<wbr>swift: fn.initialize(to: ThickFunction3(function: function))<br>./stdlib/private/SwiftPrivate/<wbr>ShardedAtomicCounter.swift: <wbr> (shards + i).initialize(to: 0)<br>./stdlib/public/SDK/Foundation<wbr>/NSError.swift: out.initialize(to: bridged)<br>./stdlib/public/core/UnsafeRaw<wbr>Pointer.swift.gyb: // (self.assumingMemoryBound(to: T.self) + i).initialize(to: source[i])<br>./stdlib/public/core/UnsafeRaw<wbr>Pointer.swift.gyb: // .initialize(to: (source + i).move())<br>./stdlib/public/core/UnsafeRaw<wbr>Pointer.swift.gyb: // (--dst).initialize(to: (--src).move())<br>./stdlib/public/core/Arrays.sw<wbr>ift.gyb: p.initialize(to: repeatedValue)<br>./stdlib/public/core/Arrays.sw<wbr>ift.gyb: (_buffer.firstElementAddress + oldCount).initialize(to: newElement)<br>./stdlib/public/core/Arrays.sw<wbr>ift.gyb: p.initialize(to: x)<br>./stdlib/public/core/Arrays.sw<wbr>ift.gyb: p.initialize(to: newValues[q])<br>./stdlib/public/core/Arrays.sw<wbr>ift.gyb: (base + newCount).initialize(to: next)<br>./stdlib/public/core/AnyHashab<wbr>le.swift: result.initialize(to: value)<br>./stdlib/public/core/AnyHashab<wbr>le.swift: result.initialize(to: value)<br>./stdlib/public/core/AnyHashab<wbr>le.swift: target.initialize(to: AnyHashable(value))<br>./stdlib/public/core/ArrayCast<wbr>.swift: target.initialize(to: _arrayForceCast(source.pointee<wbr>))<br>./stdlib/public/core/ArrayCast<wbr>.swift: target.initialize(to: result)<br>./stdlib/public/core/Contiguou<wbr>sArrayBuffer.swift: (resultPtr + i).initialize(to: _bridgeAnythingToObjectiveC(p[<wbr>i]))<br>./stdlib/public/core/Contiguou<wbr>sArrayBuffer.swift: p.initialize(to: source[i])<br>./stdlib/public/core/Contiguou<wbr>sArrayBuffer.swift: p.initialize(to: element)<br>./stdlib/public/core/ArrayBuff<wbr>er.swift: result.initialize(to: result.pointee)<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: target.initialize(to: _setDownCast(source.pointee))<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: target.initialize(to: result)<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: target.initialize(to: _dictionaryDownCast(source.poi<wbr>ntee))<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: target.initialize(to: result)<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: (keys + i).initialize(to: k)<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: (keys + toEntryAt).initialize(to: (from.keys + at).move())<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: (keys + i).initialize(to: k)<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: (values + i).initialize(to: v)<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: (keys + toEntryAt).initialize(to: (from.keys + at).move())<br>./stdlib/public/core/HashedCol<wbr>lections.swift.gyb: (values + toEntryAt).initialize(to: (from.values + at).move())<br>./stdlib/public/core/Reflectio<wbr>nLegacy.swift: out.initialize(to: String(reflecting: x))<br><br>./stdlib/public/core/ManagedBu<wbr>ffer.swift: p.headerAddress.initialize(to: initHeaderVal)<br>./stdlib/public/core/ManagedBu<wbr>ffer.swift: $0.initialize(to: <br>./stdlib/public/core/ArrayBuff<wbr>erProtocol.swift: (elements + j).initialize(to: newValues[i])<br>./stdlib/public/core/Sequence.<wbr>swift: ptr.initialize(to: x)<br>./stdlib/public/core/HeapBuffe<wbr>r.swift: $0.initialize(to: Header(initializer))<br>./stdlib/public/core/UnsafeBit<wbr>Map.swift: values.initialize(to: 0, count: numberOfWords)<br>./stdlib/public/core/String.sw<wbr>ift: resultStorage.initialize(to: <br>./test/api-digester/stdlib-sta<wbr>ble.json: "printedName": "initialize(to:count:)",<br>./test/Generics/slice_test.swi<wbr>ft: (newbase + i).initialize(to: (base+i).move())<br>./test/Generics/slice_test.swi<wbr>ft: (base+length).initialize(to: elem)<br>./test/Parse/pointer_conversio<wbr>n.swift.gyb: p.initialize(to: t)<br><br>./test/stdlib/Reflection.swift<wbr>:sanePointerString.initialize(<wbr>to: "Hello panda")<br><br>./test/stdlib/Builtins.swift: (buf + 0).initialize(to: value)<br>./test/stdlib/Builtins.swift: (buf + 1).initialize(to: value)<br>./test/stdlib/Renames.swift: x.initialize(e) // expected-error {{'initialize' has been renamed to 'initialize(to:)'}} {{5-15=initialize}} {{16-16=to: }} {{none}}<br>./test/stdlib/Renames.swift: x.initialize(with: e) // expected-error {{'initialize(with:count:)' has been renamed to 'initialize(to:count:)'}} {{5-15=initialize}} {{16-20=to}} {{none}}<br>./test/stdlib/Renames.swift: ptr1.initialize(with: e, count: 1) // expected-error {{'initialize(with:count:)' has been renamed to 'initialize(to:count:)'}} {{8-18=initialize}} {{19-23=to}} {{none}}<br>./test/Sanitizers/asan.swift:a<wbr>.initialize(to: 5)<br>./validation-test/stdlib/Unsaf<wbr>eBufferPointer.swift.gyb: allocated.initialize(to: 1.0, count: count)<br>./validation-test/stdlib/Unsaf<wbr>eBufferPointer.swift.gyb: allocated.initialize(to: 1.0, count: count)<br>./validation-test/stdlib/Strin<wbr>gSlicesConcurrentAppend.swift:<wbr> barrierVar!.initialize(to: _stdlib_pthread_barrier_t())<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (_keyVector(layout: layout) + keyCount).initialize(to: key)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (_valueVector(layout: layout) + keyCount).initialize(to: value)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (_valueArray + i).initialize(to: value)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: keyArray.initialize(to: key0)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (keyArray + 1).initialize(to: key1)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: valueArray.initialize(to: value0)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (valueArray + 1).initialize(to: value1)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (_keyArray + i).initialize(to: key)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (_valueArray(layout: layout) + i).initialize(to: value)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (keyArray + layout.keyCount - 1).initialize(to: appendKey)<br>./validation-test/stdlib/Proto<wbr>types/PersistentVector.swift.<wbr>gyb: (valueArray + layout.keyCount - 1).initialize(to: appendValue)<br>./validation-test/compiler_cra<wbr>shers_2_fixed/0004-rdar2056460<wbr>5.swift: p.initialize(to: element)<br>./validation-test/compiler_cra<wbr>shers_2_fixed/0003-rdar2056437<wbr>8.swift: p.initialize(to: element)<br>./validation-test/compiler_cra<wbr>shers_2_fixed/0006-rdar2058847<wbr>4.swift: p.initialize(to: element)<br>./validation-test/compiler_cra<wbr>shers_2_fixed/0010-rdar2063888<wbr>1.swift: p.initialize(to: element)<br></span></font><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 4:33 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><br><div><blockquote type="cite"><div>On Jul 18, 2017, at 11:36 AM, Taylor Swift <<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>> wrote:</div><br class="m_-4909203032506144131m_1503010331774072828m_-907934889053787745Apple-interchange-newline"><div><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div>> fix the ordering of the arguments in initializeMemory<Element>(as:a<wbr>t:count:to:)</div><div><br></div><div>I think this ordering was an attempt to avoid confusion with binding</div><div>memory where `to` refers to a type. However, it should be consistent</div><div>with `UnsafePointer.initialize`, so we need to pick one of those to</div><div>change.</div></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">This would be a non-issue had we just been consistent with the rest of the stdlib and named this argument `<span style="font-family:monospace,monospace">repeating:</span>` instead of `<span style="font-family:monospace,monospace">to:</span>`. But `<span style="font-family:monospace,monospace">ptr.initialize(repeating: 255, count: 100)</span>` doesn’t read quite as naturally in English as `<span style="font-family:monospace,monospace">ptr.initialize(to: 255, count: 100)</span>` which is why I left this idea out of the proposal. Now that you mention the problem with `<span style="font-family:monospace,monospace">initializeMemory<Element>(as:</span><span style="font-family:monospace,monospace"><wbr>at:count:to:)</span>`, it might be a good idea to add this rename back into it.</div></div></blockquote></div><br></span><div>I think `repeating` is much more clear.</div><div><br></div><div>-Andy</div></div></blockquote></div><br></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>