PatternLanguage icon indicating copy to clipboard operation
PatternLanguage copied to clipboard

Namespace scope doesn't apply to variables

Open BobSmun opened this issue 1 year ago • 0 comments

When a variable is defined inside a namespace, the namespace scope needs to be dropped to be able to access the variable

namespace test {
    bool something = true;
    bool setting in;
}

//way to access
something = false;
setting = true;

//expected way to access
test::something = false;
test::setting = true;

It also means that it is impossible to use namespaces to separate different instances of variables. In the below example, all three instances of 'something' collide with each other

bool something = true;

namespace test {
    bool something = true;
}

namespace test2 {
    bool something = true;
}

BobSmun avatar Nov 30 '24 06:11 BobSmun