They occur by default because I was too lazy to check if a macro appeared as a variable in an expression:
MyArray() {
cmd1;
cmd2;
cmd3;
}
My Array ends up being an integer pointer to args list, the only immediate integer in the system, every other variable is a char * back to source.
So, I had this choice, bother to check of just let the expression unit do arrays. This is Default, the boot syntax. It does the minimal and normalizes the side effects, so treating macros as arrays is in. We can make is a method jump:
Local = MyArray();
This should work in expression execution, making local a symbol of type macro. Then:
Local = Local + 2; # works, two tokens per command in the macro list
Local(); # works
It is an oddity,. I also added a cheesy cheat, since all immediate integers are always indices into args list, I know when a 64 bit value is an integer or a char *. I have a cheesy cheat, mainly because adding the cheat was simpler than adding the memory address check and syntax error call.
Everything normally remains a char * until consumed in a final expression, then the accumulator carries it.
The system therefore inherited the addition of 64 bit integer when macros were enabled. Used inly as index, mapped to args list.. The only first class 64 bit immediate values it allows are up the MAXARGS. To create an immediate integer one must create a macro. Therefore, by default, the Default is zero:
Default() { do some stuff}
Sets Default to 0, the first index into args. There is no other way to make an immediate integer, the best you can do, by default, is point to a digit string, and these have no restrictions. Try this:
Default() {0 1 2 3 4 5 6 7 8 9} // Does what you think
Local = Default;
MyVar = 18 * Local; # Should work, I would think.
Now this does not works exactly, yet, I actually have to remove code to make is work, this is what I mean, minimal. make everything go through the same path, quit checking, let the user manual tell the tale, as an outcome. Like, OK what do I do? Just remove any attempt at typedefing things, the things we get are the outcome, just keep that outcome looking like c syntax.
I am making expressions robust, simple and correct at the moment. So The key routine is ValToken, it takes an args list element and returns a real integer value for the real integer accumulator. It will always return something, even if it defines a new variable. As long as that routine returns some default, intuitive value, then fine, nothing crashes and expr_cmd is simple as pie. And that is the default method.
No comments:
Post a Comment