Hi Christian, On Fri, Feb 27, 2015 at 3:38 PM, Christian Stoller <stol...@leonex.de> wrote:
> It is not a bug. FALSE as a return value of substr() is the identificator > for an error (e.g. invalid arguments), as it is stated in the > documentation: > [...] > "It is documented that way" and "it is not a bug" are two very different things. In that case, the semantics of `substr()` are just wrong. It makes a lot more sense for a sub-string function to silently allow reading before the beginning and past the end of a string. Moreover, the *conditions* under which `substr()` returns FALSE looks completely arbitrary, see http://3v4l.org/gtFjk -- in a nutshell: so it is OK to read past the beginning, it is OK to try to get more characters than the string has, but it is NOT OK to try to start reading past the end? This behavior is unpredictable, and as a consequence using `substr()` properly would require a lot of painful and unnecessary up-front checks. It traditionally did not matter, because of the fluid scalar casts. But if we want now to introduce stricter casts, we are going to have to tackle this problem, we cannot just dismiss it as a programming error. Damien