on Wed Jul 05 2017, Jens Persson <swift-users-AT-swift.org> 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 of this number, expressed as an integer of the > same > /// type. > public func signum() -> Self > } > > The Swift API Design Guidelines doesn't say very much about computed > property vs method with no arguments, but it seems like signum() violates > them, no?
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, and IIRC our numerics people thought a function was more appropriate. In general, though, we were unable to come up with solid guidelines for the use of properties vs. functions. You can read more about this in the thread that starts here: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/007927.html Cheers, -- -Dave _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users