Accessing global variables and definitions

These functions can be used to access or modify the values of global definitions. Global definitions include global functions, classes, variables and constants. Some of these functions refer to the definition using the fully qualified name of the definitions, such as io::File, and some refer using a numeric id. Numeric ids can be obtained using the AGlobalByNum function as described below, or by using a _P variant macro when defining the global definition, described in section Variant macros.

AValue AGlobal(AThread *t, const char *name)
Return the value of a global definition. The name must be the fully qualified name of the definition. All available definitions, including private ones, can be accessed using this function without having to respect the ordinary Alore visibility rules. The only requirement is that the module containing the definition has been imported at least once and it has not been freed by the garbage collector. Raise a direct exception on all error conditions. Example:
AValue intType = AGlobal(t, "std::Int");
int AGetGlobalNum(AThread *t, const char *name)
Get the internal numeric id of a global definition. The valid argument values are the same as for the AGlobal function above. The numeric id can be used as an argument for the functions described below and some additional functions such as ARaiseByNum. Raise a direct exception on all error conditions.
AValue AGlobalByNum(int num)
Return the value of a global definition using a numeric id to refer to the definition.
void ASetGlobalByNum(int num, AValue v)
Set the value of a global variable using a numeric id to refer to the variable. The num argument must refer to a global variable. No error checking is performed: num must refer to a global variable, not a constant or another type of definition.
void ASetConstGlobalByNum(AThread *t, int num, AValue v)
Set the value of an empty global constant using a numeric id to refer to the constant. The num argument must refer to an empty global constant defined using A_EMPTY_CONST or A_EMPTY_CONST_P.

Note: You must use ASetConstGlobalByNum only in the Main function of a module, and only for initializing empty global constants defined in that module.