<div dir="ltr">On Wed, Jan 17, 2018 at 2:04 AM, David Sweeris <span dir="ltr"><<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Sent from my iPhone<br>
<span class=""><br>
> On Jan 16, 2018, at 23:45, Jonathan Hull via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> Mainly semantics.<br>
><br>
> We could technically use Int instead of having a Bool type (just using 1 and 0). We don’t do that since Int and Bool have intrinsically different meanings in code.<br>
><br>
> What I am saying is that parameters that take the range 0 to 1 typically have a fundamentally different meaning (or at least a different way of thinking about them) than Doubles. It would be nice to be able to see that distinction when using APIs.<br>
><br>
> With both this and the Angle type, I am pointing out areas where, due to historical reasons in C, we have conflated a bunch of types which have different behavior, and then just expect programmers to be conscientious enough to use them correctly in each case. These types/numbers all have a different forms of dimensionality.<br>
><br>
> I’d like to discuss that before we lock everything down.<br>
<br>
</span>+1 (although I think a “normalized to [0, 1]” type would be more useful than a “percentage” type)<br></blockquote><div><br></div><div>Bool is not a good example; it permits precisely two logical values (0 and 1). By contrast, if you're going to support 1000%, then your type supports the same values as the underlying storage. As I wrote in a different thread, one way to look at a type is the set of values that a variable can have.</div><div><br></div><div>What is your limiting principle here if you think that a range that's not enforced makes a value become of a different type? Often, a 1-5 rating system is used. Sometimes, it's 1-4 or 1-10. And of course, a "3" on a 1-5 scale means something very different from a "3" on a 1-10 scale. Should ScaleFrom1To5 be its own type? And also ScaleFrom1To4 and ScaleFrom1To10?</div><div><br></div><div>Besides, even supposing a percentage type would be in high demand, there's no need for its inclusion in the standard library. It's very easy to implement on your own in a third-party library. Moreover, custom operators will allow you to define a postfix `%`, and then you could write: `let x = 100%`. Throw in some heterogeneous arithmetic operators and you could do almost any math you want.</div></div></div></div>