[swift-corelibs-dev] Foundation and NSDecimal

2016-09-27 Thread Alex Blewitt via swift-corelibs-dev
The Framework function 

NS_INLINE BOOL NSDecimalIsNotANumber(const NSDecimal *dcm)

has been imported into Swift on both Darwin and Linux as

:type lookup NSDecimalIsNotANumber
@discardableResult func NSDecimalIsNotANumber(_ dcm: 
Swift.UnsafePointer) -> Swift.Bool
:type lookup NSDecimalIsNotANumber
func NSDecimalIsNotANumber(_ dcm: Swift.UnsafePointer) -> 
Swift.Bool

However I think this should instead be imported as a member function on the 
Decimal type, instead of passing through a pointer.

extension Decimal {
  public func isNotANumber() -> Bool
}

This may not have been picked up by the automatic renaming progress because 
it's a const pointer, and because it's an NS_INLINE defined in the header, 
instead of in an implementation file.

There are some other global constants NSDecimalMaxSize and NSDecimalNoScale, 
which should probably be implemented as constants in the Decimal type as well 
e.g.

extension Decimal {
  public let maxSize = 8
  public let noScale =  Int16.max
}

Since this would need to be fixed in both the Swift Linux foundation 
implementation and the Darwin overlay (and it would be a breaking change) what 
is the right process to be able to fix this?

Alex
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] Collection.map doesn't call `makeIterator()`

2016-09-27 Thread Tim Vermeulen via swift-corelibs-dev
The implementation of Collection.map can be found here: 
https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L1265-L1286

It uses repeated subscripts, rather than `makeIterator()`. Isn’t this a 
problem? I overloaded `makeIterator` on a custom collection once (I think it 
was a binary tree) because an iterator would be able to iterate the collection 
more efficiently than subscripts would (both O(n), but with a lower constant 
factor). If `makeIterator` isn’t overloaded, then subscripts are used anyways 
(by `IndexingIterator`). Wouldn’t it make more sense to use an iterator in 
Collection.map instead, in order to benefit from a possibly more efficient 
iterator than the default one?
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev