Hi.
I, today, want to share something big with you all.
It's kind of a tutorial / guide for the more advanced bgt developer covering the creation and management of namespaces.
So what's a namespace:
Namespaces are commonly structured as hierarchies to allow reuse of names in different contexts. As an analogy, consider a system of naming of people where each person has a proper name, as well as a family name shared with their relatives. If, in each family, the names of family members are unique, then each person can be uniquely identified by the combination of first name and family name; there is only one Jane Doe, though there may be many Janes. Within the namespace of the Doe family, just "Jane" suffices to unambiguously designate this person, while within the "global" namespace of all people, the full name must be used.
So how do I use them in bgt:
If you have to function sets.
int var = 2;
void a() {
}
bool b() {
}
and
int var = 5;
void a() {
}
and bool b() {
}
that would overlap and give you a nice compile error.
But if you put them inside a namespace like:
namespace name1 {
int var = 2;
void a() {
}
and bool b() {
}
}
and:
namespace name2 {
int var = 5;
void a() {
}
and bool b() {
}
}
It wouldn't overlap, and your code will run fine.
Calling stuff from a namespace:
if you have a namespace like this:
namespace math {
double pi = 3.141592653589793;
int add(int a, int b) {
// function body and return.
}
int divide(int a, int b) {
// function body and return.
}
int multiply(int a, int b) {
// function body and return.
}
int subtract(int a, int b) {
// function body and return.
}
}
you can call functions or get variables from that namespace by doing the following:
math::pi;
math::add(5,6);
and so on.
I hope this helps somebody.
If you have any questions just ask.
Oh, and if you want to see more tutorials on undocumented stuff from bgt or just bgt programming in general do tell
Have a good day
NicklasMCHD -