Re: Going from string to identifier

2018-02-21 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 22:22:55 UTC, Meta wrote: (I'm not sure if the available compiler implementations actually enforce this) Yes it does, example ``` enum s = q{€}; ``` gives: `Error: character 0x20ac is not a valid token`

Re: Going from string to identifier

2018-02-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 22:22:55 UTC, Meta wrote: Mixins have to be full declarations. They need to be full declarations, full statements, or full expressions, depending on the context where they appear. string s = mixin("teste"); so that is a full expression and thus legal.

Re: Going from string to identifier

2018-02-21 Thread Meta via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 22:11:04 UTC, Jean-Louis Leroy wrote: Here's what I am trying to do: mixin template MakeFun(string ID, int X) { int mixin(ID)() { return X; } } mixin MakeFun!("one", 1); // int one() { return 1; } Alas I get: makefunc.d(3): Error: no identifier for declarato

Going from string to identifier

2018-02-21 Thread Jean-Louis Leroy via Digitalmars-d-learn
Here's what I am trying to do: mixin template MakeFun(string ID, int X) { int mixin(ID)() { return X; } } mixin MakeFun!("one", 1); // int one() { return 1; } Alas I get: makefunc.d(3): Error: no identifier for declarator `int` makefunc.d(3): Error: found `{` when expecting `;` makefunc.d(3):