I agree that this would be a nice addition! However, don't assume that because the Arduino IDE has it, this makes an easy port to ESPbasic. Library functions generally would be easy to add as it is a matter of adding a few lines of customized "boiler plate" to the source code. By contrast, the Case/Switch construct is inherent in C and not a library function. I'm pretty sure that to add it would require that it be written as a primitive flow control within the interpreter.
Would it be faster that a series of if/else statements? I think so. The processing, while it would still have to perform all the same conditionals, would not have to run each one through the command decoding (which is curiously a long series of if/else statements and not switch/case last time I looked). So the overhead would be one command decode plus N conditionals (and some scanning through the lines of BASIC code) versus N command decodes and N conditionals.
A cool alternative that would work in many cases would be to have the ability to GOTO or GOSUB dynamically. This would be an easy addition I think. When parsing the GOTO command (for example), check to see if the first character of the label is a bracket ( [ ). If it is, behave normally. If not, treat the operand as an argument such as a quoted string constant OR as a string variable. This way, the following would all behave the same way:
Code: Select alllet destination="[place]"
goto destination
Code: Select alldim destination(10)
let destination(5)="[place]"
goto destination(5)
This would allow us to set up vector tables. I have a cool ESPbasic application that allows me to define devices of any kind attached to the ESP8266 and it does sensing, reporting and device manipulation over the internet. By saving these device definitions in a local file, I can make hardware changes WITHOUT having to change any ESPbasic code and it all works. The problem is that I use a lot of if/else sequences to determine and perform the right functions based on the device parameters. It would be SO much easier for me to use a vector table as follows:
Code: Select alllet destinations="[po] [pwo] [servo] [pi] [pwi] [ai] [temp]"
' Magical code happens here which encounters a device on pin P performing function FNC with state S (for outputs)
let place=word(destinations,fnc)
gosub place
' Code continues with return value in RV set by called routine
wait
[po]
io(po,p,s)
return
[pi]
rv = io(pi,p)
return
[ai]
rv = io(ai)
return
' Etc, etc.