| > I have some experience in C++, and I am familiar enough with the standard library to remember that operator[] doesn't check bounds while the at member function does. Everybody knows you're supposed to check pointers for being null, and yet time and time again developers fail. As long as you rely on human nature and provide one API which is simple, convenient, obvious and dangerous and one which is complex, inconvenient, non-obvious and safe, you will just drive users towards the former. > I would assume that the Firefox C++ programmers know this as well. However, maybe I'm wrong or have too much faith? Just because they know when quizzed doesn't mean they'll always remember when actually doing. Even less so when subscripting is safe in pretty much every other language which provides array subscripting, and ::at… only exists in C++? > IMO calling the at function isn't particularly verbose No, but it's still more verbose and less intuitive than [], especially given the above (that tons of languages use [], and very few have an at method) > A good way to dissuade people from making unidiomatic choices is to make them more verbose. Indeed. |
and has been my experience with unwrap
they dont want people to use it but the alternative is so verbose and clunky