[swift-evolution] Implicit truncation
salutis at me.com
Mon May 22 08:06:15 CDT 2017
> On 22 May 2017, at 14:18, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> What are the "subtle bugs all over the place" that you observe, and what did those users expect to happen?
They pretty much universally expect the value to be rounded. When this happens, I tell them about this language called C (… insert long story here ...) and we replace "Int(foo)" with "foo.rounded()”. We write a unit test and move on. So far, so good. However, two weeks later, they do it again. And again. If the initializer said “truncating” or something along those lines, I’m sure they wouldn’t pick that one. They are all smart people, it’s just that there’s absolutely no “visible clue” and they don’t expect this to be the default behavior.
P.S. I haven’t followed the “integer protocols” debate and had no idea that “this issue is settled” and that it "cannot go back”. Also, I have no time nor interest to "bikeshed endlessly”. I just wanted to share real-world experience/observation with smart people in here (like you) to improve the language going forward.
More information about the swift-evolution