Re: Mixin/static if issue

2021-08-25 Thread DLearner via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 22:57:23 UTC, jfondren wrote: Contrast: [...] ```d void main() { import std.stdio; uint TestVar = 5; string mxnWrite_Size_t(string VarName)() { static if (typeof(mixin(VarName)).stringof == "uint") { return `write("` ~ VarName ~

Re: Mixin/static if issue

2021-08-25 Thread jfondren via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 22:52:23 UTC, DLearner wrote: On Wednesday, 25 August 2021 at 22:33:00 UTC, H. S. Teoh wrote: [...} I think what you meant to write is: static if (typeof(mixin(VarName)).stringof == "uint") { You want the type of the variable named by VarName, not the

Re: Mixin/static if issue

2021-08-25 Thread DLearner via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 22:33:00 UTC, H. S. Teoh wrote: [...} I think what you meant to write is: static if (typeof(mixin(VarName)).stringof == "uint") { You want the type of the variable named by VarName, not the type of VarName. T I understand your reasoning, but: ```

Re: Mixin/static if issue

2021-08-25 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 25, 2021 at 10:16:39PM +, DLearner via Digitalmars-d-learn wrote: > Please see below: > ``` > void main() { >import std.stdio; > >uint TestVar = 5; > >string mxnWrite_Size_t(string VarName) { ^^ Obviously, VarName is a string.

Mixin/static if issue

2021-08-25 Thread DLearner via Digitalmars-d-learn
Please see below: ``` void main() { import std.stdio; uint TestVar = 5; string mxnWrite_Size_t(string VarName) { static if (typeof(VarName).stringof == "uint") { return `write("` ~ VarName ~ `");`; } else { return `writeln("Apparently TestVar not a