Re: [swift-users] More questions about protocol/value programming

2016-08-02 Thread Rick Mann via swift-users
Thanks, Karl, that's great! In the end, I think I need to use classes, because I do have reference semantics in my model (e.g. a part definition can be referenced by multiple instances). But this helps me get my head around the techniques. Thanks! > On Aug 1, 2016, at 21:39 , Karl wrote: > >

Re: [swift-users] More questions about protocol/value programming

2016-08-01 Thread Karl via swift-users
A protocol can require that a certain initialiser exists, but it can’t provide a default implementation (you can add initialisers in a protocol extension IIRC, but then they must delegate to an actual, required initialiser). A protocol is not the same thing as a subclass. Any type could conform

[swift-users] More questions about protocol/value programming

2016-08-01 Thread Rick Mann via swift-users
In my schematic capture app, I had a class hierarchy that started with Element. From that I derived PartDefinition and PartInstance. Element has an immutable UUID, name, and description. Element knows how to encode itself as XML by conforming to an XMLCoding protocol. Now I'm trying to make Ele