<div dir="ltr">FWIW, the label should be "repeating".</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 11:42 PM, Taylor Swift via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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><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/<wbr>SwiftPrivatePthreadExtras/<wbr>SwiftPrivatePthreadExtras.<wbr>swift: result.initialize(to: block(arg))<br>./stdlib/private/<wbr>StdlibUnittest/<wbr>OpaqueIdentityFunctions.swift:<wbr> ptr.initialize(to: x)<br>./stdlib/private/<wbr>SwiftReflectionTest/<wbr>SwiftReflectionTest.swift: anyPointer.initialize(to: any)<br>./stdlib/private/<wbr>SwiftReflectionTest/<wbr>SwiftReflectionTest.swift: fn.initialize(to: ThickFunction0(function: function))<br>./stdlib/private/<wbr>SwiftReflectionTest/<wbr>SwiftReflectionTest.swift: fn.initialize(to: ThickFunction1(function: function))<br>./stdlib/private/<wbr>SwiftReflectionTest/<wbr>SwiftReflectionTest.swift: fn.initialize(to: ThickFunction2(function: function))<br>./stdlib/private/<wbr>SwiftReflectionTest/<wbr>SwiftReflectionTest.swift: fn.initialize(to: ThickFunction3(function: function))<br>./stdlib/private/SwiftPrivate/<wbr>ShardedAtomicCounter.swift: <wbr> (shards + i).initialize(to: 0)<br>./stdlib/public/SDK/<wbr>Foundation/NSError.swift: out.initialize(to: bridged)<br>./stdlib/public/core/<wbr>UnsafeRawPointer.swift.gyb: // (self.assumingMemoryBound(to: T.self) + i).initialize(to: source[i])<br>./stdlib/public/core/<wbr>UnsafeRawPointer.swift.gyb: <wbr> // .initialize(to: (source + i).move())<br>./stdlib/public/core/<wbr>UnsafeRawPointer.swift.gyb: <wbr> // (--dst).initialize(to: (--src).move())<br>./stdlib/public/core/Arrays.<wbr>swift.gyb: p.initialize(to: repeatedValue)<br>./stdlib/public/core/Arrays.<wbr>swift.gyb: (_buffer.firstElementAddress + oldCount).initialize(to: newElement)<br>./stdlib/public/core/Arrays.<wbr>swift.gyb: p.initialize(to: x)<br>./stdlib/public/core/Arrays.<wbr>swift.gyb: p.initialize(to: newValues[q])<br>./stdlib/public/core/Arrays.<wbr>swift.gyb: (base + newCount).initialize(to: next)<br>./stdlib/public/core/<wbr>AnyHashable.swift: result.initialize(to: value)<br>./stdlib/public/core/<wbr>AnyHashable.swift: result.initialize(to: value)<br>./stdlib/public/core/<wbr>AnyHashable.swift: target.initialize(to: AnyHashable(value))<br>./stdlib/public/core/<wbr>ArrayCast.swift: target.initialize(to: _arrayForceCast(source.<wbr>pointee))<br>./stdlib/public/core/<wbr>ArrayCast.swift: target.initialize(to: result)<br>./stdlib/public/core/<wbr>ContiguousArrayBuffer.swift: <wbr> (resultPtr + i).initialize(to: _bridgeAnythingToObjectiveC(p[<wbr>i]))<br>./stdlib/public/core/<wbr>ContiguousArrayBuffer.swift: <wbr> p.initialize(to: source[i])<br>./stdlib/public/core/<wbr>ContiguousArrayBuffer.swift: <wbr> p.initialize(to: element)<br>./stdlib/public/core/<wbr>ArrayBuffer.swift: result.initialize(to: result.pointee)<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: target.initialize(to: _setDownCast(source.pointee))<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> target.initialize(to: result)<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: target.initialize(to: _dictionaryDownCast(source.<wbr>pointee))<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> target.initialize(to: result)<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> (keys + i).initialize(to: k)<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> (keys + toEntryAt).initialize(to: (from.keys + at).move())<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> (keys + i).initialize(to: k)<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> (values + i).initialize(to: v)<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> (keys + toEntryAt).initialize(to: (from.keys + at).move())<br>./stdlib/public/core/<wbr>HashedCollections.swift.gyb: <wbr> (values + toEntryAt).initialize(to: (from.values + at).move())<br>./stdlib/public/core/<wbr>ReflectionLegacy.swift: out.initialize(to: String(reflecting: x))<br><br>./stdlib/public/core/<wbr>ManagedBuffer.swift: p.headerAddress.initialize(to: initHeaderVal)<br>./stdlib/public/core/<wbr>ManagedBuffer.swift: $0.initialize(to: <br>./stdlib/public/core/<wbr>ArrayBufferProtocol.swift: <wbr> (elements + j).initialize(to: newValues[i])<br>./stdlib/public/core/Sequence.<wbr>swift: ptr.initialize(to: x)<br>./stdlib/public/core/<wbr>HeapBuffer.swift: $0.initialize(to: Header(initializer))<br>./stdlib/public/core/<wbr>UnsafeBitMap.swift: values.initialize(to: 0, count: numberOfWords)<br>./stdlib/public/core/String.<wbr>swift: resultStorage.initialize(to: <br>./test/api-digester/stdlib-<wbr>stable.json: "printedName": "initialize(to:count:)",<br>./test/Generics/slice_test.<wbr>swift: (newbase + i).initialize(to: (base+i).move())<br>./test/Generics/slice_test.<wbr>swift: (base+length).initialize(to: elem)<br>./test/Parse/pointer_<wbr>conversion.swift.gyb: p.initialize(to: t)<br><br>./test/stdlib/Reflection.<wbr>swift:sanePointerString.<wbr>initialize(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:<wbr>a.initialize(to: 5)<br>./validation-test/stdlib/<wbr>UnsafeBufferPointer.swift.gyb:<wbr> allocated.initialize(to: 1.0, count: count)<br>./validation-test/stdlib/<wbr>UnsafeBufferPointer.swift.gyb:<wbr> allocated.initialize(to: 1.0, count: count)<br>./validation-test/stdlib/<wbr>StringSlicesConcurrentAppend.<wbr>swift: barrierVar!.initialize(to: _stdlib_pthread_barrier_t())<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (_keyVector(layout: layout) + keyCount).initialize(to: key)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (_valueVector(layout: layout) + keyCount).initialize(to: value)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (_valueArray + i).initialize(to: value)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: keyArray.initialize(to: key0)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (keyArray + 1).initialize(to: key1)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: valueArray.initialize(to: value0)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (valueArray + 1).initialize(to: value1)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (_keyArray + i).initialize(to: key)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (_valueArray(layout: layout) + i).initialize(to: value)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (keyArray + layout.keyCount - 1).initialize(to: appendKey)<br>./validation-test/stdlib/<wbr>Prototypes/PersistentVector.<wbr>swift.gyb: (valueArray + layout.keyCount - 1).initialize(to: appendValue)<br>./validation-test/compiler_<wbr>crashers_2_fixed/0004-<wbr>rdar20564605.swift: p.initialize(to: element)<br>./validation-test/compiler_<wbr>crashers_2_fixed/0003-<wbr>rdar20564378.swift: p.initialize(to: element)<br>./validation-test/compiler_<wbr>crashers_2_fixed/0006-<wbr>rdar20588474.swift: p.initialize(to: element)<br>./validation-test/compiler_<wbr>crashers_2_fixed/0010-<wbr>rdar20638881.swift: p.initialize(to: element)<br></span></font><br></div><div class="HOEnZb"><div class="h5"><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_4218669878599003191m_-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></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>