Local static variables are often useful (mainly to avoid using module-level global variables).
Anyway, this has already been asked (whishlist forum) many years ago and perhaps several times. Since it has not been implemented, there will be compelling reasons and it is useless to ask for it again.
Or, maybe there were just too many other higher priority things in the fire, or maybe the intent was not well explained. In any case, while I have seen the issue raised years ago, I do not recall seeing any sort of official response much less hint of a compelling reason against. I think I have shown that the request could be implemented without any structural redesign as "under the covers" in Java, the variables would be global privates exactly as they are now. Perhaps there is some
philosophical reason for not doing it, but I see no technical or substantive resource reason, so I will exercise my right as a licensed member to beat my head against the wall by asking again.
In fact, I see two instances of the request coming up in this forum previously. The first is by you in 2017:
As you know, in some cases local static variables would be very useful, to avoid using global module variables; this is a recent post in which you could use them: https://www.b4x.com/android/forum/threads/add-currency-format-for-edittext.80836/#post-512379
www.b4x.com
There was no response in that thread by anybody.
The second one was by Marc S in 2019:
How do you create a static variable within a class, so that it retains it's value between calls? the only way I can see this being done is by using one of the .tag properties of a view created within the class.
www.b4x.com
This thread had some responses. Cableguy suggested using constants, as he also suggested for me above (and I thank him for the idea), but as I responded above to him, so Mark S also pointed out in the 2019 thread that a constant is not a variable. It cannot act as a state variable because its value cannot be changed. Others suggested using globals, which makes sense since that thread was not specifically about static variables local to a sub, but of course that does not address the issue of a local static raised by you and me. Finally there was a response by Erel that the request was not clearly defined, and that was the end of the discussion.
I see that you also raised the same thing, obliquely, in this 2020 thread which was on a different topic.:
I have a global and local variable with the same name. If I change the local variable, it overrides the global one. Example below. Demo is also attached. This is not how it works in other languages. A local variable will never override a global variable. Bug or "feature"? Sub Globals...
www.b4x.com
Once again, there was no answer, official or otherwise, on the subject.
I did not find any other instances of this request using the forum search "static local".
So I am clearly defining the request: make a change to the compiler/preprocessor that detects a static variable declaration in a sub, modify the name of that variable to prepend the sub name so that the variable is unique on a module level, and elevate that variable to treat it exactly as a global private variable. No other changes are required to implement this.
Reason? Exactly what you stated in 2017 and again here, that this would allow programmers to avoid global module variables except in cases where doing so makes sense, i.e., when they need to be accessed by multiple subs in the module.
If there is a good reason (or even a not good reason) for declining to do it, it would be helpful to have that stated in a response so that some fool like me doesn't come along five years from now, fails to find an answer via search, and then posts the request again.