Re: issue with static foreach

2021-07-22 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 22 July 2021 at 18:16:54 UTC, Tejas wrote: On Thursday, 22 July 2021 at 18:06:07 UTC, Paul Backus wrote: On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote: Why does this work? ```d import std; void main() { mixin("int") a; writeln(a); } ``` You can mix in a type: h

Re: issue with static foreach

2021-07-22 Thread Tejas via Digitalmars-d-learn
On Thursday, 22 July 2021 at 18:06:07 UTC, Paul Backus wrote: On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote: Why does this work? ```d import std; void main() { mixin("int") a; writeln(a); } ``` You can mix in a type: https://dlang.org/spec/type.html#mixin_types Looks like

Re: issue with static foreach

2021-07-22 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote: Why does this work? ```d import std; void main() { mixin("int") a; writeln(a); } ``` You can mix in a type: https://dlang.org/spec/type.html#mixin_types

Re: issue with static foreach

2021-07-22 Thread Tejas via Digitalmars-d-learn
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote: On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote: ... it compiles no-more: Error: found `End of File` when expecting `}` following compound statement ... what I am doing wrong ? You'll get the same error from this code: ```d

Re: issue with static foreach

2021-07-22 Thread someone via Digitalmars-d-learn
On Thursday, 22 July 2021 at 08:16:43 UTC, Patrick Schluter wrote: What an unreadable mess. Sorry. Indeed LoL !!! I would have done something like that: ```d mixin(format! `case r"%1$s"d : classTickerCustom%1$s lobjTicker%1$s = new classTickerCustom%1$s (lstrSymbolID);

Re: issue with static foreach

2021-07-22 Thread someone via Digitalmars-d-learn
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote: Each individual string has to compile on its own. You'll have to concatenate strings and then mixin them. I forgot about that !

Re: issue with static foreach

2021-07-22 Thread Basile B. via Digitalmars-d-learn
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote: On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote: ... it compiles no-more: Error: found `End of File` when expecting `}` following compound statement ... what I am doing wrong ? You'll get the same error from this code: ```d

Re: issue with static foreach

2021-07-22 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote: ``` Now, if uncomment those two innocuous commented lines for the if (true == true) block: ```d labelSwitch: switch (lstrExchangeID) { static foreach (sstrExchangeID; gstrExchangeIDs) { mixin(r"case r"d, `"`, sstrExchangeID, `"`,

Re: issue with static foreach

2021-07-21 Thread jfondren via Digitalmars-d-learn
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote: ... it compiles no-more: Error: found `End of File` when expecting `}` following compound statement ... what I am doing wrong ? You'll get the same error from this code: ```d unittest { mixin("{"); mixin("}"); } ``` https://d

issue with static foreach

2021-07-21 Thread someone via Digitalmars-d-learn
The following code chunk compiles perfectly: ```d labelSwitch: switch (lstrExchangeID) { static foreach (sstrExchangeID; gstrExchangeIDs) { mixin(r"case r"d, `"`, sstrExchangeID, `"`, r"d : "d); mixin(r"classTickerCustom"d, sstrExchangeID, r" lobjTicker"d, sstrExchangeID, r" = new classT