Hi there Daniel,
In swift-corelibs-foundation/Foundation/NSArray.swift on line 347 there is a comment that says TODO: Bounds checking . Since that just call objectAtIndex, I think the bounds checking should be done inside of objectAtIndex.
Note we have another pull request open in this area too: https://github.com/apple/swift-corelibs-foundation/pull/15
I asked there to rebase into a single commit; once that’s done, maybe we can accept that and then move it to the implementation of objectAtIndex.
My question, though, is what should be returned if the index is out of the array bounds? The methods don’t throw, so I don’t think we can raise an exception. And I don’t think we can return nil because the method is supposed to return a non-optional AnyObject. What about using assert or precondition?
We’ve made a decision to use fatalError(“description that makes sense”) in cases of programmer error. Obj-C Foundation would have thrown an exception (since we use ObjC exceptions exclusively for indication of programmer error there).
I’m super excited to be a part of this community!
Glad to have you here.
On Dec 3, 2015, at 7:14 PM, Daniel Strokis <email@example.com> wrote:
swift-corelibs-dev mailing list