[swift-evolution] [swift-evolution-announce] [Re-Review] SE-0104: Protocol-oriented integers

David Sweeris davesweeris at mac.com
Wed Feb 22 12:48:00 CST 2017


> On Feb 22, 2017, at 10:39 AM, Max Moiseev <moiseev at apple.com> wrote:
> 
> Free functions are much less discoverable. Think about the code completion, for example.
> 
>> On Feb 22, 2017, at 6:01 AM, David Sweeris <davesweeris at mac.com <mailto:davesweeris at mac.com>> wrote:
>> 
>> 
>> On Feb 21, 2017, at 20:46, Xiaodi Wu via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>>> Sign, perhaps, can be thought of as "part of a number," but signum refers to the signum function (http://en.wikipedia.org/wiki/Sign_function <http://en.wikipedia.org/wiki/Sign_function>) defined as:
>>> 
>>> -1 if x < 0
>>> 0 if x = 0
>>> 1 if x > 0
>>> 
>>> 1 isn't really "part of" 42, for instance, at least not in the sense that 42 and + are "part of" 42.
>> 
>> Should it be a stand-alone function, then?

Eh, maybe… At least in Xcode, autocomplete works for free functions. I was just thinking about how people who already know about “signum" would expect it to work. Like if a mathematician sits down to write something in Swift, are they more likely to try “signum(x)” or “x.signum” first?

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170222/c0d8257f/attachment.html>


More information about the swift-evolution mailing list