On Friday, 29 December 2023 at 21:25:44 UTC, user1234 wrote:
[...]
Thanks, and the ideas are useful,
but please see below, suppose:
```
void main() {

   size_t var1 = 1;
   size_t var2 = 3;
   size_t var3 = 5;
// ... Many other variables defined.

   char[4] VarName;
//   ...

// And some complicated logic finishes:
   VarName = cast(char[4])("var2");

// _Without_ previously storing the addresses of
// all the 'var' variables, how do I get access
// to the variable currently (run-time) named in VarName?
//
// Is there a compiler-provided
// 'introspection' function that would do this?
//
// Labouring the point: If there is an int variable intVar,
// whose name ("intVar") is held in a string variable strVar,
// then there is a compiler function __fnAddrVar() such that
// assert(__fnAddrVar(strVar) == &intVar)
// is true?
}
```

Reply via email to