The underlying issue here is that the length of a text delimited array is ambiguous when there isn’t any text, which also means there is no delimiters. Data Arrays don’t have this issue, there is no ambiguity between a zero element data array and a data array of one empty element.
I don’t know if I ever said that this is the “correct” response, if I did, please accept my apology. Since this situation is ambiguous, there is no “correct” response. Depending on the needs of your application, the correct response might be 1, or it might be zero. When I originally wrote the arraysize( function 25+ years ago, I had to pick one of these results, and I picked 1. I could have picked zero. Either way, the result would be correct for some applications and wrong for some others. The extract( function can also calculate an arraysize (by using -1 for the item number), and it gives the other result, it treats empty text as having zero elements.
If I was starting from scratch today, maybe I would change the arraysize( result to be zero instead of one, if for no other reason than I am quite tired of this topic! Though I suspect if the result was 0 instead of 1 there would be complaints that this was incorrect as well, in fact, in my programming I think that returning 1 has generally been more useful to me, though I’m not 100% sure about that. But the decision made on this years ago is irrevocable – if it was changed now, it would silently cause terrible bugs in much existing code, including and especially in Panorama’s internal libraries.
The same ambiguity applies to arrayfilter, and Gary, you are correct that this ambiguity was resolved differently in the case of arrayfilter than arraysize. So this is certainly inconsistent. Sorry about that. Again, this cannot possibly be changed without silently causing massive bugs.
This is a case where I would definitely do it the same way again if starting over. The example you cite is quite unusual, what would be the point in a real application of filtering with a fixed value? The more common situation is using this statement (or function) as a filter – it’s right in the name! For example, suppose I set up a filter that adds ( and ) to each array element.
In this case, I think it would make no sense for the result to be
(). The result in this case should be empty text, and that’s what it is.
When making a movie, there is a person specifically in charge of continuity, to try to make sure that any inconsistencies are rooted out before the movie is released. A movie is shot over a few weeks. On a software project that over decades has pushed far beyond it’s original goals, unfortunately some continuity problems are going to crop up. This is one of them, and definitely not the only one in Panorama.