[swift-evolution] [Planning][Request] "constexpr" for Swift 5
Félix Cloutier
felixcloutier at icloud.com
Thu Aug 3 23:32:13 CDT 2017
> Le 3 août 2017 à 17:44, Taylor Swift via swift-evolution <swift-evolution at swift.org> a écrit :
>
> On Thu, Aug 3, 2017 at 8:20 PM, Karl Wagner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>> The root cause, of course, is that the VLAs require new stack allocations each time, and the stack is only deallocated as one lump when the frame ends.
>>
>> That is true of alloca(), but not of VLAs. VLAs are freed when they go out of scope.
>>
>
> Learned something today.
>
> Anyway, if the goal is stack allocation, I would prefer that we explored other ways to achieve it before jumping to a new array-type. I’m not really a fan of a future where [3; Double] is one type and (Double, Double, Double) is something else, and Array<Double> is yet another thing.
>
> They are completely different things.
>
> [3; Double] is three contiguous Doubles which may or may not live on the stack.
>
> (Double, Double, Double) is three Doubles bound to a single variable name, which the compiler can rearrange for optimal performance and may or may not live on the stack.
To be clear, there is no Swift value type that guarantees that the order in which fields are laid out is the same as the order in which they're declared. It's not just tuples. (Structs imported from C are always laid out with their C layout, of course.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170803/65c760c0/attachment.html>
More information about the swift-evolution
mailing list