[swift-users] Should a queue be value type or reference type?

Kwame Bryan kwame.bryan at gmail.com
Tue Jul 26 06:41:13 CDT 2016


As Quinn said, this is a hard question to answer. As Dave said in wwdc 15.
Will you make comparisons over your collection. There's great examples of
how you can do this. Unfortunately, without a usecase. This response is
philosophical.
On Jul 26, 2016 3:37 AM, "Quinn "The Eskimo!" via swift-users" <
swift-users at swift.org> wrote:

>
> On 25 Jul 2016, at 15:10, 褚 晓敏 via swift-users <swift-users at swift.org>
> wrote:
>
> > So what should it be, according to API design guidelines?
>
> It’s hard to answer this question without more information about your
> specific context.  However, I think it’s safe to say that Swift expresses a
> preference for value types.  OTOH, reference types exist for a reason:
> sometimes you really do want to model shared mutable state.
>
> My approach to this is to design the data structure as a value type and
> see how that works out for clients.  If the client code looks good, you’re
> set.  OTOH, if the client code is painful, you need to rethink.
>
> Share and Enjoy
> --
> Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160726/3a02264d/attachment.html>


More information about the swift-users mailing list