Hello, dear M2000 Users,
The latest revision of M2000 make the interpreter faster, of about 17% (less time to compute), so we can say we have a speedup of x1.2 times,(1/0.83=1.204) so we can say the new revision make the Interpreter 20% faster.
How this done?
M2000 Interpeter always execute the source as is. Which means there is no conversion to a tokenized form. Also there is no AST construct. That is no very bad, for a language which are made for expansion as we go, for the last 26 years). The purpose for using the M2000 Interpreter surely is not for \time critical programs. Much of the time consuming work done from objects and internal code which can do things like rotation of bitmaps. So all the Interpreter is a function with a series of helping functions. The code run consuming the string which hold it. Some time maybe I change this, but for now when we do this Print 12+10 first the Print statement removed from string, then the Expression evaluation stage get the first number 12 then get the plus sign and looking for another number or another sign before the number (you can do this 12+-+-12 and is ok)) or an open parenthesis and so on.
A numeric expression may have strings on it: "aaa" is a string expression, but "aaa">"bbb" is a Boolean one (a numeric for M2000). So before this revision and before the 11th version, there was strictly two kind of expressions, the string and the numeric. When we start the numeric evaluator, there was a looking ahead mechanism to find if there is a logic operator, when strings find in front at the expression, so at this point conclude that in front exist a numeric expression or a string one. So if it is a string return without exclude any value (literal) or name (variable or constant). For versions lower than 11, the string variables and functions was all with a $ as suffix, so alfa$ was treated as string, and this was the same with a alfa$(), where the "things" inside parenthesis skipped from the look ahead system as irrelevant for determinate the type of expression. So from version 11 we may have an alfa variable as a string one. That was a difficult situation for holding the IsExp() function for numeric (and now string results) and the string only IsStrExp() function. Each of these functions knows all the internal functions, the numeric for IsExp() and string fot IsStrExp(). So there was a logical() function which find looking ahead if there is a string expression and and a logic operator. If not return false without removing anything. Now for the Revision 20 of version 14, this function drop the look ahead part and also the internal string comparison part. The logical() function called from the IsExpA() function inside IsExp() function, for each value which we want to process. So now we don't have the look ahead part because now the process done for strings too inside IsExpA(). The IsStrExp() works because some time we want to get a parameter only as string. This IsStrExp() call the IsString() and get the value and then see if there is the plus operator to get another string, to concatenate them, and repeat this until no other operation exist. IsExpA() which work for a number of different types, work nice for strings too. If we place a value an operator and a value and then an operator plus and a string then we get error. I do that because this can be a mistake, So 10+10+"ok" give an error, but 10+"ok"+10 give a string 10ok10, and also "ok"+10+10 give a string ok1010. IsExp() the shell of the numeric/object expressions, works for all numeric types plus the complex numbers (1,-2i) or (a,b i) are complex notation for making complex numbers, also works for dates, bytes, long long and biginteger (which are objects), plus with Group type of objects which have operators as functions so a A+A can be a sum of two numeric types including complex and biginteger, a concatenation of two string values or a produce of an object from object A which knows the operator "+" as a function (which call the evaluator) and pass the value of expression at part after the "plus" operator.
To do this functionality I have to make some changes in the code, to work as expected. Maybe I am not 100% for all situation, but at the long run I will find any mistake or not prepared code to this level of functionality.
Another two new things about this revision:
- We can use Ctrl / (also Ctrl 4 works the same) to apply comment or uncomment lines of code (one or more). Because / may change to other keys (other virtual keys), I improve the code to find this for the specific keyboard language in use. Also Keypress() function now have a ! switch to address the same situation we want a character code to be pressed but we didn't know the scan code, but the system know it and we just supply the parameter as character Unicode code.
Also we can use Ctrl 2 for lower case (no selected text, or convert also for selected text), and Ctrl 1 for upper case (no selected text, or convert also for selected text). So if you want fast capital key you press Ctrl 1 and we get the caps lock to ON for sure without looking the keyboard.
- The last thing do magic or something like this. We want to open a second m2000 program in front of our program, through our program. Before this magic, the new program open, but if our own program got the focus the other program go to background, and our program hide it. That is not bad, because all programs do that. But what if we want the new program which we start from our program want to stay in front of our program? To do that we pass the hWnd (the window handler) of the BACK (the real form of M2000 console) to the new program and that program has to run the Show statement using this number as a parameter (this is new, the Show get optional a parameter). You can see how this work with the Clock module (which run the Clock1, in another M2000.exe). So when we open the clock the form of the clock get a parent form, our console form, so Windows manager always show the clock in front of the parent (our console form). It is the same as the Help form, or the Control form, or the user forms which we make as children of the console form. If we start the Form44 module which make three windows we can put the Clock (which run on own M2000.exe) between the user forms because these have the same parent, the console form. If out form terminate, the other program just do nothing about it, like there is no parent for it; We don't have family problems here;
Another example is the Compiler. When we compile one of the examples we ask to use M2000 Transpiler (compile to M2000 starements) or Virtual Machine (byte code for a virtual machine - now running as a M2000 program also). If we choose Transpiler we Asked if we want the execution done in the console or not (by default is not) so if we press enter a new M2000.exe start and run as child window in front of our console (with transparency also). I am thinking to make a way to make forks and these can be used to form a parent child connection. I am thinking about the way the forked code to access global variables of the parent code.
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.