I don't like it either, and I agree that some form of a[ifXxx: i] would be less confusing than a[safe: i] and a[checked: i]. I think a[checking: i] is almost as confusing as a[checked: i] (since it sort of implies that a[i] wouldn't be checking the index). Perhaps a[existing: i] ...
And IMHO the current proposal would actually add rather than remove an exception, as explained in my previous post. I think other options should be considered, like:
-
Using a subscript for a new type (eg SpecialArrayIndexThatIsCorrespondingToDictionarysKeyAndSetsElement, but sensibly named), for consistency with other collection types (again motivated by my previous post).
-
Using a method, eg
a.element(ifExistingFor: Index) -> Element?