[swift-evolution] RFC: Preventing Retain Cycles (Memory Ownership Model)

Andrew Bennett cacoyi at gmail.com
Fri Jul 29 22:33:49 CDT 2016


Interesting, I'm not familiar with the history of the feature in Rust. Are
you able to provide more details on what went wrong in practice?

This proposal may be different, this is not attempting to do it without GC.
What I'm suggesting still uses ARC (assuming you were counting ARC as GC).
It does provide the compiler many opportunities to optimise ARC though.

I really like what Rust ended up with, but I'm concerned that it's very
complicated, and I want to explore alternatives. From
https://doc.rust-lang.org/book/ownership.html:

However, this system does have a certain cost: learning curve. Many new
> users to Rust experience something we like to call ‘fighting with the
> borrow checker’.




On Sat, Jul 30, 2016 at 1:22 PM, Joe Groff via swift-evolution <
swift-evolution at swift.org> wrote:

> Rust attempted this sort of type-directed cycle prevention early in its
> development, when it was attempting to provide language-supported shared
> references without GC, and it didn't work out well for them in practice.
>
> -Joe
>
> > On Jul 29, 2016, at 6:42 PM, Andrew Bennett via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > I'd like an opt-in way to verify and prevent unintentional strong
> references in Swift.
> >
> > This can be used to verify ownership structures, and ultimately avoid
> retain cycles.
> >
> > Read a draft proposal here:
> >
> https://github.com/therealbnut/swift-evolution/blob/therealbnut-explicit-ownership/proposals/NNNN-explicit-ownership-type-attribute.md
> >
> > TL;DR:
> >
> > If you have any questions please read the proposal before asking here.
> >
> > It's an opt-in attribute that defines a whitelist of types something can
> own. For example:
> >
> > @owns(TypeA, TypeB) struct TypeC { ... }
> >
> > I wrote this a few months ago, but we weren't accepting additive
> proposals. Now we're explicitly looking for something like this:
> >
> > Memory ownership model: Adding an (opt-in) Cyclone/Rust inspired memory
> ownership model to Swift is highly desired by systems programmers and folks
> who want predictable and deterministic performance (for example, in real
> time audio processing code).  More pertinent to the goals of Swift 4, this
> feature is important because it fundamentally shapes the ABI.  It informs
> code generation for “inout", how low-level “addressors” work in the ABI,
> impacts the Swift runtime, and will have a significant impact on the type
> system and name mangling.
> >
> > - Chris
> >
> > ----
> >
> > Here's a link to the version of the proposal when I sent this email.
> > _______________________________________________
> > swift-evolution mailing list
> > swift-evolution at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160730/14a5eb2f/attachment.html>


More information about the swift-evolution mailing list