Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-06 Thread Dave Abrahams via swift-users
on Wed Jul 05 2017, Jens Persson wrote: > On Wed, Jul 5, 2017 at 11:50 PM, Dave Abrahams via swift-users < > swift-users@swift.org> wrote: > >> … >> As a name, signum falls into the “term-of-art” category, so at least >> that part is in conformance to the guidelines. In specialized areas >> lik

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Jens Persson via swift-users
On Wed, Jul 5, 2017 at 11:50 PM, Dave Abrahams via swift-users < swift-users@swift.org> wrote: > … > As a name, signum falls into the “term-of-art” category, so at least > that part is in conformance to the guidelines. In specialized areas > like this one, I generally defer to the domain experts,

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Jens Persson via swift-users
On Wed, Jul 5, 2017 at 6:52 PM, Zhao Xin wrote: > For your specific question, `func signum() -> Self` returns `Self`, which > can't be used in property. > `var signum:Self { return self }` will generate an error "'Self' is only > available in a protocol or as the result of a method in a class". >

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Dave Abrahams via swift-users
on Wed Jul 05 2017, Jens Persson wrote: > Why is eg the BinaryInteger.signum() a method and not a computed property? > > public protocol BinaryInteger … { > /// Returns `-1` if this value is negative and `1` if it's positive; > /// otherwise, `0`. > /// > /// - Returns: The sign

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Zhao Xin via swift-users
For me, a noun is a property, a verb is a method. So `foo` is a property, `calculateFoo()` is a method. For your specific question, `func signum() -> Self` returns `Self`, which can't be used in property. `var signum:Self { return self }` will generate an error "'Self' is only available in a proto

[swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Jens Persson via swift-users
Why is eg the BinaryInteger.signum() a method and not a computed property? public protocol BinaryInteger … { /// Returns `-1` if this value is negative and `1` if it's positive; /// otherwise, `0`. /// /// - Returns: The sign of this number, expressed as an integer of the same