[swift-evolution] [Pitch] Renaming sizeof, sizeofValue, strideof, strideofValue
xiaodi.wu at gmail.com
Thu Jun 2 01:23:45 CDT 2016
On Thu, Jun 2, 2016 at 12:37 AM, Patrick Smith <pgwsmith at gmail.com> wrote:
> Yes but, if they weren’t functions now, what would be the best design?
Dave's suggestions then were made in the context of a language that had
`.dynamicType`. The question today is how best to align these functions
with `type(of:)`. If we were to ignore this context, I'm not sure on what
basis we could judge whether a property or function is 'best' for these
> How many Swift developers will be using this functionality? Less than 1%?
> I trust Dave’s judgement because he is in that small group.
I would caution against this assumption. I'm not a particularly advanced
developer by any stretch of the imagination, and I've been using
`strideof()` plenty of times while doing some math with
Accelerate.framework and Metal buffers. That said, Dave's in a very small
group indeed, the group that wrote these functions to start with.
> On 2 Jun 2016, at 3:27 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> On Thu, Jun 2, 2016 at 12:24 AM, Patrick Smith <pgwsmith at gmail.com> wrote:
>> I really like this idea. This IMO is lower level functionality than
>> `type(of:)` (née dynamicType), so I think it makes sense for it to be
>> grouped under its own domain, the MemoryLayout type.
>> Plus MemoryLayout can be extended with new convenience methods.
>> I’m fine with those old methods being removed, but I never use them so!
>> Is it the same as calling type(of:) then using that with MemoryLayout? I
>> imagine they could be fixit’d easily, and that they compile down to the
>> same underlying code.
> I'm actually souring to the idea. It goes in the diametrically opposite
> direction from dynamicType. There, something was changed from being
> property-like to being function-like. Here, Dave's proposal would take
> something that's a function and turn it into a property. Hmm.
>> On 2 Jun 2016, at 3:05 PM, Xiaodi Wu via swift-evolution <
>> swift-evolution at swift.org> wrote:
>> 2. Dave A. and others expressed the opinion that these should probably
>> not be global functions; his preference was for:
>> MemoryLayout<T>.size // currently sizeof()
>> MemoryLayout<T>.spacing // currently strideof()
>> MemoryLayout<T>.alignment // currently alignof()
>> 3. Dave A. proposed that sizeofValue(), strideofValue(), and
>> alignofValue() are better off removed altogether. I don't know if people
>> are going to be happy about this idea.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution