I thought that was clever given that tcl's reference counter was signed and it only uses positive values. So we made it unsigned and got the bit for free.
So yeah, there is some sloppiness there. Tcl tends to use "" as sort of a null or undef so lots of stuff just works but no promises on that.
This is sloppy simply because the Tcl die hards (are there any left?) refused to see the value of undef, a value for a variable that said there is no value. We used it all over the place, there clearly is value. They didn't see that, Little never got pushed back into the Tcl source base so Tcl never thought about undef.
It is what it is, we live in an imperfect world. I tried.
Consider
char *p = 0;
some complicated code that should have set p but didn't...
char c = *p; // SEGV
So do you have a way to push that error all the way back to wherever you think it should be pushed?
The array access should error out on the line that it happens.
The dereference could print a line of the last assignment, but this isn't what was being talked about.
In Tcl, stuff just gets auto expanded on assignment and returns "" (I think) on dereference. We chose to return undef. I'm not sure what the problem is.
I also explained a huge difference between the two already (you know how large an array is and can detect an out of bounds access when it happens).
We just thought it would be clever to return undef if you were out of bounds, which tcl code would see as "" which is what you'd get in tcl. But Little code could actually tell you are past the end.
In my mind, which many have argued isn't the best, it's a reasonable design.
You keep trying to push backwards to a design point where arrays are fixed in size at declaration and that is not how tcl (or Little) works.
You can see how this is getting confusing.
> So there is no error to catch.
Thing is, you're already catching the error because "Little code could actually tell you are past the end" and "return undef if you were out of bounds" - you're just smooshing the error under the carpet into an `undef` return rather than bombing out with an OOB error (which is what I think GP was actually after.)
(If Little returns `undef` for OOB and `""` for in-bounds-not-set, you can detect the OOB access error in your own code but that hasn't been made clear, I don't think?)
The thing that GP was asking for, an OOB error, is not a thing in a language where there are no bounds.
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.