Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Both cases are an index error. It's just for some other reasons in case of the section, the error is represented by an empty object and it's left to user to handle the result.

This could easily conceal the indexing error unless the caller code explicitly checks the length of the returned section.



> This could easily conceal the indexing error unless the caller code explicitly checks the length of the returned section.

An empty returned section doesn’t mean the index was out of bounds (`a[0:0]`); if you want to make sure you have to check the length before slicing, like in Go.


Here it is. It only underscores the ambiguity of such handling of the section indexes. Flagging the index error would make this less ambiguous/silent.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: