[swift-evolution] [pitch] remove global sqrt<T: FloatingPoint>

Chris Lattner clattner at apple.com
Mon Jul 11 18:10:21 CDT 2016


> On Jul 11, 2016, at 4:00 PM, Stephen Canon <scanon at apple.com> wrote:
> 
>>> 
>>> I’m fine with placing a generic implementation in Darwin.C.  I would include that as part of this change.  Post Swift 3, we should also have a Swift math module that provides the usual sqrt<T: MathTypeOrWhatever>(_: T) operations.
>>> 
>>> However, I’m not totally convinced we want every math operation we think of in the global namespace *by default*, and I’d like to avoid painting ourselves into a corner where sqrt( ) just sticks out like a sore thumb in the base stdlib for all time.
>> 
>> I’m not sure what problem you’re trying to solve.  I think you agree that people should be able to write a generic function and use “sqrt(x)” where x is some FloatingPoint bound type, right?  If so, is it just the concern about it being injected into every program that imports (e.g.) Foundation?
> 
> Right, this is only about the concern that it's injected into every program that doesn’t even import anything, under the assumption that folks may push back against doing that for *every* function in a future Math module.
> 
> This is a very minor issue, which would only change anything in the short term for most users, and which has already produced more discussion than I thought possible =)

Ah, in that case, I agree that putting it into the overlay for Darwin.C (instead of in the stdlib) makes sense.

-Chris


More information about the swift-evolution mailing list