News for hackers. Stuff that matters.
Re:My Vision of D’s Future by mhh__ on Tuesday October 15, 2019 @09:21PM (#21266090)
Assuming I formatted it right, I made your example shorter

  import std;

  template Math(char Op) {
     auto eval(T, U)(T l, U r) {
        static foreach(x; "+-*/") {            
         if (Op == x)
          mixin("return l ", x, " r;");        
        }        
    }
  }

  static immutable result = Math!('+').eval(1, 2) + Math!('*').eval(3.0, 3.0);

  void main() {
    writeln(result);
  }
Re:My Vision of D’s Future by ZootAllures91 on Tuesday October 15, 2019 @11:32PM (#21266816)
Yeah, that works too. I was trying not to get too crazy I guess. And also just show all the various levels of "static".