[swift-evolution] Philosophy of Swift
Dave Abrahams
dabrahams at apple.com
Thu Jun 9 10:03:59 CDT 2016
on Wed Jun 08 2016, Paul Cantrell <paul-AT-bustoutsolutions.com> wrote:
>> On Jun 8, 2016, at 6:13 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> on Wed Jun 08 2016, Paul Cantrell <swift-evolution at swift.org> wrote:
>>
>>> The interplay of the first two and the last two is what makes the
>>> language unique. For example, structs have a simple, high-level
>>> programmer model — “pass by value semantics” — but the compiler jumps
>>> through all those COW hoops to make them perform _most_ of the time as
>>> if they were C structs statically allocated and then passed by
>>> pointer.
>>
>> I have no argument with most of what you wrote, but this part is just
>> inaccurate. Plain structs are never CoW'd, and the compiler doesn't
>> introduce CoW. The standard library implements CoW “manually” for
>> specific types like Array and String.
>
> So then only language/runtime magic is isUniquelyReferenced(), and all
> the other “hoops” are in the standard lib?
>
> I guess I just lump compiler and standard library together in my mind
> too carelessly!
It's the right user model most of the time. In this case, though, you
don't want to give people the impression that these things will be done
for them.
--
Dave
More information about the swift-evolution
mailing list