www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20053] New: mixin doesn't work for many expressions

https://issues.dlang.org/show_bug.cgi?id=20053

          Issue ID: 20053
           Summary: mixin doesn't work for many expressions
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

Lots of expressions don't work as mixin, and you need to expand the mixin to
include the whole statement as a workaround.

Eg, doesn't work:
  alias impl = mixin("Thing." ~ fieldName); // ERROR

Ugly workaround:
  mixin("alias impl = Thing." ~ fieldName ~ ";");

This really inhibits readability when the code is even remotely complex.
I run into endless examples like this regularly. We can do better than this.

--
Jul 14 2019