Agreed. Imagine this:<br><br> let distance = (x * x + y * y).squareRoot()<br><br>That reads extremely foreign to me.<br><br>Why not provide this as a static function that takes Self on the protocol so that conformances can specialize it, and have the protocol-constrained global function sqrt<T: FloatingPoint> call T.sqrt?<br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 11, 2016 at 3:42 PM Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Jul 11, 2016, at 2:28 PM, Stephen Canon via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> Post SE-0067 FloatingPoint provides the usual global operators, as well as a single global function:<br>
><br>
> func sqrt<T: FloatingPoint>(_: T) -> T<br>
><br>
> It seems out of place and lonely, and it would be nice if we can keep the default members of the global namespace to a minimum.<br>
><br>
> I’d like to suggest removing this global from FloatingPoint while keeping the existing global functions for concrete types in the Darwin.C module. The square root operation would still be available for all FloatingPoint types as `.squareRoot()`.<br>
><br>
> I would also plan to provide this and other math.h-ish globals in a future (post swift 3) Math module.<br>
<br>
I’m very concerned with this. Why not do exactly the opposite? Remove the concrete operations from Darwin.C and replace it with a single generic one?<br>
<br>
The rationale for using global functions here is that they are “terms of art” in numerics nomenclature. If they aren’t, then we should consistently eradicate all the global operations:<br>
<br>
assert(Double.pi.sine == 0.0)<br>
<br>
Is this the direction you want to go?<br>
<br>
-Chris<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>