How to mixin finction name?
Andrey
saasecondbox at yandex.ru
Sun Apr 14 10:07:30 UTC 2019
Hi,
I want to do something like this:
> void main()
> {
> enum letters = ['A', 'B', 'C'];
> static foreach(ch; letter)
> {
> void mixin("print" ~ ch)(uint i)
> {
> writeln(ch, " - ", i);
> }
> }
>
> printB(6);
> }
Create some function in loop and use it. But I don't know how to
mixin names?
Output:
> onlineapp.d(59): Error: no identifier for declarator void
> onlineapp.d(59): Error: found i when expecting . following uint
> onlineapp.d(59): Error: found ) when expecting identifier
> following uint.
> onlineapp.d(60): Error: found { when expecting ,
> onlineapp.d(61): Error: found ; when expecting ,
> onlineapp.d(62): Error: expression expected, not }
> onlineapp.d(63): Error: found } when expecting ,
> onlineapp.d(65): Error: found ; when expecting ,
> onlineapp.d(66): Error: expression expected, not }
> onlineapp.d(67): Error: found End of File when expecting ,
> onlineapp.d(67): Error: found End of File when expecting )
> onlineapp.d(67): Error: found End of File when expecting ;
> onlineapp.d(67): Error: found End of File when expecting }
> following compound statement
> onlineapp.d(67): Error: found End of File when expecting }
> following compound statement
More information about the Digitalmars-d-learn
mailing list