[FUTURE][SYSTEMML-2078] Add support for global variables
Hi, Here is a PR for adding support of global variables. We can define variables in global scope or function scope. For a function call, it can reference variables from its parent scope, i.e., global or its superior function scope.
Thanks for review
Can an Admin verify this patch?
Sorry for the late response but I would like to play around with this a bit before doing the review. I'll come back to this in a few days.
@EdgarLGB things look good :). Tested global-variables-test.dml.
I was wondering why you choose to use + operator instead of a function call.
Eg:
gv = 10
setglobal(gv) or
global gv
Thanks @krishnakalyan3 for testing! In fact, my idea is to define a global variable and check if it is modified after the function call which tries to modify the global variable. And I'm not sure that I understand your question. Well, I used it for concatenating the string.
@EdgarLGB thanks for the clarification.
Hi @Baunsgaard and @kev-inn , would you investigating this PR. Is this changeset in line with systemds direction.
cc @EdgarLGB
Meanwhile, I think not supporting global variables might be better in the long run as it keeps functions (except for explicit reads/writes) side-effect free. Back when discussing this feature, it included two sub problems (1) builtin global constants like NaN, PI, INF, as well as (2) different function scoping rules (with global access). Since (1) has already been introduced (see https://github.com/apache/systemml/commit/4a822a22c88b579e935a1b09051c1fe236e18a4b) and meanwhile we extended the list functionality to pass parameters easier along function call graphs, there is no more a real need for globals. However, I would leave this PR open, in case we come back to it - then this would be an excellent starting point.