Re: Another wishlist for 43s Message #4 Posted by Andrew Nikitin on 14 July 2013, 9:25 p.m., in response to message #3 by Marcus von Cube, Germany
Marcus, I am aware of the preprocessor's labels feature.
What it is missing is the "local labels" (or local symbols as i referred them above), which, in my opinion, greatly improve readability and reduce mental effort of generating and tracking one-off random labels that are used to implement if/then/else and loops.
I implemented it in my own "proof of concept" preprocessor (which also translates utf8 to ascii, that is why my source contained all those &# characters) to demonstrate their advantage.
Here I reuse the "1H" local label 4 times. This is enabled by the fact that the direction of reference (forward or backward) is specified explicitly at the point of reference (as <1F> or <1B>, respectively). Now, in wp34s, the direction is encoded in the opcode (skip or back), so there is no need for specifying the direction in the label, but I did it anyway for demonstration purposes.
Also, same trick can be applied to LBL labels. If the backward version of GTO (say, GTB) is added, so they form a pair analogous to SKIP/BACK, this will allow reuse of numeric labels to a much greater extent. In my experience using local symbols, I never needed to use more than 6. So, the programmer can use and reuse LBL 00 .. LBL 09 for one-off flow control, LBL 80 .. 99 for internal subroutines, and the rest for keyboard handling. For example. Or whatever.
Writing JMP instead of SKIP or BACK actually reduces readability, since BACK, most likely, means a loop and SKIP is most likely a part of if/then/else and when you write JMP you leave the reader (human reader, that is) with need to investigate which of the 2 possibilities you actually meant.
|