-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove use of globals #15
Comments
As an example, tokenTreeIndex, which is has an extern in tasks.c and is defined in lexer.c. In tasks.c its used twice in task_3. All thats occuring is that its being set to 0. In one case its being set to zero just prior to taskControl(...) enabling task_4. Could I add an argument to taskControl(...) - a value to pass to a task? The complication becomes the issue of the corporative multitasking nature of the code? How about a setter and getter? An area of data which is basically global, but has a more managed atomic reads and writes of these shared values. The values would be assigned as static in this memory manager. |
With recent commit into master (a7ff768), the first steps in removing globals has begun. Started out small, that is - two integer variables used to track the integer and string numbers used in the interpreter (intNum and strNum). A new source has been added, varman (variable manager) which can now set, get and increment each of these values. The globals for both intNum and strNum have been removed. |
Removed two additional int globals, intVarsIndex and strVarsIndex. The next global int to remove would be tokenTreeIndex, but this one is referenced over 100 times in the code, so much more care and time needs to be taken. |
Wow - just don't feel comfortable with all these global variables. Some of it has to do with no malloc functions?? Maybe - not a good excuse, but certainly would have been one way to solve this would have been some form of memory management, malloc type thing.
The text was updated successfully, but these errors were encountered: