[swift-corelibs-dev] NSAttributedString attributesAtIndex return an optional.

Brent Royal-Gordon brent at architechies.com
Tue Dec 8 16:56:00 CST 2015


> This may be better for the swift-evolution list, but I really do not like the fact that subscripting is a "hard" error. I think the language should have as little hard errors as possible to improve on how much the compiler can check for you.

I think the idea is that, if you’re subscripting incorrectly, chances are you didn’t anticipate the possibility that your subscript might fail and probably didn’t write code that’s prepared to handle that error. If you did anticipate that possibility, you would have made sure there was a range check in the first place.

Ultimately, since Swift.org Foundation is meant to present the same interface as Apple Foundation, I don’t think we have much of a choice about this anyway. Apple Foundation’s version of this method is non-optional and non-throwing. If we deviate from that, we lose compatibility.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-corelibs-dev mailing list