Re: Satisfying a protocol - getters vs. functions

2016-06-25 Thread Quincey Morris
On Jun 25, 2016, at 12:49 , William Squires wrote: > > I was looking at the problem from the caller's end (i.e. client code), not > the callee's end, so the semantic requirements (such as getters not being > able to modify instance variables) aren't a consideration here. It does, subtly, affec

Re: Satisfying a protocol - getters vs. functions

2016-06-25 Thread William Squires
Oops, I should have noted: 1) A getter doesn't require (or allow, IIRC?) parentheses, whereas a func call does, even if it takes no arguments. 2) I was looking at the problem from the caller's end (i.e. client code), not the callee's end, so the semantic requirements (such as getters not being a

Re: Satisfying a protocol - getters vs. functions

2016-06-25 Thread Quincey Morris
On Jun 25, 2016, at 11:59 , William Squires wrote: > > But would it make a difference if you have a getter named description that > has type String? They’re not interchangeable in Swift. The semantics are not even the same: getters aren’t allowed to mutate instance variables, for example (enfo

Satisfying a protocol - getters vs. functions

2016-06-25 Thread William Squires
Let's take the CustomStringConvertible protocol, for example. You can use this to allow your class to "display" itself in a human-friendly format (for debugging, let's say), and you implement a function called description() -> String. But would it make a difference if you have a getter named de