I know that global variables are traditionally not the way to go, but I figured I'd present my question anyway. For a college senior project for a software engineering class we are supposed to create a 3AC calculator using quads. One of the requirements is to have a display for the instruction memory (the 3AC in quadruple format) and the data memory (the integer value of the quad). Furthermore, the program should tell the user how many temporaries exist in memory and display them to the user in the following format:
Operand3 ::= Operand1 operator Operand2
Thus, my question is:
When I create my function to take in the quad to determine the value to be put into the data memory "register" I am going to be essentially creating a standard form equation. Therefore,
(+, 3, 4, t0)
t0 = 3 + 4
which very closely resembles the format for the 3AC temporaries. If I wanted to store these into, say, a List or some sort of collection and use them in another function, is there any way I could do this without establishing the collection as a global variable?
I can't see a means of doing this due to the limitations of variable passing between functions relating to specific elements on the GUI. We're supposed to display the temporaries one at a time with a means to go between them (e.g. a scroll bar) but this scroll bar would need access to the collection of temporaries (due to the handler for the scroll bar being a separate function). So, if there's a way to accomplish this without creating the collection as a global variable please enlighten me as it will help me in not only this small project but in the future as well.
Edited 7 Years Ago by theories: n/a