I read everywhere that referential transparency and side-effects are mutually exclusive for all functions, however, what about the case in which a function changes some state that has no effect on its outputs. For example:
global_variable = 0
def foo(a,b):
global_variable += 2
return a + b
# Other code ...
Now, if you call this function, it seems to fit the standard definition of referential transparency while it also changes state and thus has side-effects.
With that in mind, I wonder, do I misunderstand referential transparency or the even the idea of a side-effect? Is it correct to say that the function foo is both referentially transparent and has side-effects?
To an extent, I feel that it is counter-productive to expand the definition of referential transparency with the condition that side-effects with no effect on the return value of a function still excludes functions from being considered referentially transparent.