Norbert Nemec wrote:
Jason House wrote:
Would sum!( "i", "a[i]*b[i]" ) be acceptable? That should be achievable with a template mixin that does string mixins under the hood.

It is indeed a solution for the problem, but I still don't like it too much. For one, writing expressions as strings always feels awkward. Even though D can handle these strings at compile time, it just doesn't feel like writing native D code.

Beyond this "gut feeling" I also see two technical problems:

* code editors do not recognize the string content as code, so they cannot offer syntax highlighting or more advanced language tools

You can use the q{ } string syntax.

* the syntax does not allow nesting:

    sum(i)( a[i] * sum(j)(b[i,j]*c[j]) )

This is a much bigger problem. It's not too difficult if you allow only a set of built-in operations, but if you allow user-defined operations, it's tough.

Template alias parameters have got much more powerful since I wrote BLADE, so maybe it's more feasible now.

Reply via email to