3 ms·
Not quite - variables are references to objects, there's nothing that restricts global variables themselves to only reference a single _instance_ of an object.
by dwaite 6y ago
Not quite - variables are references to objects, there's nothing that restricts global variables themselves to only reference a single _instance_ of an object.
That said, a global singleton (and global state in general) is usually an anti-pattern; having pretty much any code be able to depend on the state makes it very difficult to evaluate the impact of a change.