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

What would you want a language to do if you try to access an array offset that doesn't exist except for give you a clear error?


You are kind of making my point. In tcl, they'd just give you "", but you can't tell the difference between "past the end of the array" or an element where you said

set foo[i] = ""

In Little you can tell, we'll return undef (your clear "error" though in these languages it is a supported feature, not an error). So we support the auto expanding array but give you that extra bit of info that you are past the end.


Well, it's that line of thought that prompted my question. It is, of course, a well-known source of problems in C that it will uncomplainingly dereference an invalid pointer.


That's actually C avoiding a run time error which is the opposite of what you asked.


You are right, it is avoiding a runtime error, but there have been, and continue to be, many cases where it leads to one. I suppose am asking about things that are undefined behavior in C.




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

Search: