Re: Indirect access to variables.

2023-12-30 Thread DLearner via Digitalmars-d-learn
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 compl

Re: Indirect access to variables.

2023-12-29 Thread user1234 via Digitalmars-d-learn
On Friday, 29 December 2023 at 17:11:49 UTC, DLearner wrote: Compile-time: [...] Is there a 'foo1' that yields 1 from the snippet below? [...] Similarly, execution-time, is there a foo2 that wields 2 from the snippet below: [...] **compile-tome** ```d void main() { import std.stdio;

Indirect access to variables.

2023-12-29 Thread DLearner via Digitalmars-d-learn
Compile-time: Is there a 'foo1' that yields 1 from the snippet below? ``` void main() { import std.stdio; size_t var1 = 1; char[4] Txt = cast(char[4])("var1"); writeln(foo1(Txt)); } ``` Similarly, execution-time, is there a foo2 that wields 2 from the snippet below: ``` void mai