5:45 PM
...yeah wow that is bad in a lot more complicated ways than I thought
Global flags/state influencing fine grained behavior is always ???, and scoping it like that seems on paper like it could mitigate the problem, but there's still just no winning
Because if it is scoped, then indices passed from outside have to conform to the scoped IO, and if it isn't scoped, internal logic manipulating the indices can completely unfixably break
I guess one way to make it slightly gentler could be to tag individual integers in the input with the calling scope's IO so that if they're used directly for indexing they get shifted to compensate...? But then that failing with any kind of manipulation, even stuff that mathematically cancels out (or maybe addition and subtraction could also preserve the flag), would just be room to surprise the user
@lyxal Oh yeah I kinda forgot to reply to this LMAO
I generally don't think about it since it's just kinda there, but...
@emanresuA This can come up extra in Jelly because i
has the opposite argument order from e
, but depending on what you're using the result for you can also get away with the likes of f
And some other fun hacks with that work just as well with 0-indexing, provided you have modular indexing either way (i.e. the not-found value is always going to point to the last element if you do index back in with it)
Also worth considering corollaries, like whatever the J
equivalent is--is it more useful to have that as all-positive, or are there tricks you can use with the first element being zero