<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 26, 2016, at 00:36, Quinn The Eskimo! via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">On 25 Jul 2016, at 15:10, 褚 晓敏 via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">So what should it be, according to API design guidelines?<br class=""></blockquote><br class="">It’s hard to answer this question without more information about your specific context. &nbsp;However, I think it’s safe to say that Swift expresses a preference for value types. &nbsp;OTOH, reference types exist for a reason: sometimes you really do want to model shared mutable state.<br class=""><br class="">My approach to this is to design the data structure as a value type and see how that works out for clients. &nbsp;If the client code looks good, you’re set. &nbsp;OTOH, if the client code is painful, you need to rethink.</div></div></blockquote><br class=""></div><div>Rather than look for an answer in the API design guidelines, try choosing between value and reference <i class="">semantics.</i>&nbsp;If you pass the queue to another part of the program, and that other part of the program pops some things off of it, should that change be reflected in the original queue? Or would you expect passing the queue somewhere to make a completely independent copy? As you say, DispatchQueue clearly works the first way (and should), and Array works the second way (and should). What should your type do, in your application?</div><div><br class=""></div><div>One more note: it’s easier to go from value semantics to reference semantics, by making the value be a property of a class instance. So if you make a value-typed queue, you could use it to implement DispatchQueue.</div><div><br class=""></div><div>Hope we’ve given you some places to start.</div><div>Jordan</div><br class=""></body></html>