[swift-evolution] Should we rename "class" when referring to protocol conformance?

Dave Abrahams dabrahams at apple.com
Sat May 7 15:53:51 CDT 2016


on Sat May 07 2016, Matthew Johnson <matthew-AT-anandabits.com> wrote:

> Sent from my iPad
>
> On May 7, 2016, at 2:21 AM, Andrew Trick via swift-evolution
> <swift-evolution at swift.org> wrote:
>
>         On May 6, 2016, at 5:48 PM, Dave Abrahams via swift-evolution
>         <swift-evolution at swift.org> wrote:
>
>                 I don’t mean to imply that it is the *only* valuable
>             property. However, it I (and many others) do believe it is an
>             extremely valuable
>             property in many cases. Do you disagree?
>
>         I think I do. What is valuable about such a protocol? What generic
>         algorithms could you write that work on models of PureValue but don't
>         work just as well on Array<Int>?
>
>     class Storage {
>     var element: Int = 0
>     }
>
>     struct Value {
>     var storage: Storage
>     }
>
>     func amIPure(v: Value) -> Int {
>     v.storage.element = 3
>     return v.storage.element
>     }
>
>     I (the optimizer) want to know if 'amIPure' is a pure function. The
>     developer needs to tell me where the boundaries of the value lie. Does
>     'storage' lie inside the Value, or outside? If it is inside, then Value is a
>     'PureValue' and 'amIPure' is a pure function. To enforce that, the developer
>     will need to implement CoW, or we need add some language features.
>
> Thank you for this clear exposition of how PureValue relates to pure functions.
> This is the exact intuition I have about it but you have stated it much more
> clearly.
>
> Language features to help automate CoW would be great. It would eliminate
> boilerplate, but more importantly it would likely provide more information to
> the compiler.

Whoa; Andy never suggested this would help automate CoW.  Are you
suggesting that?  How would it work?

-- 
-Dave


More information about the swift-evolution mailing list