A little challenge...

Norbert Nemec Norbert at Nemec-online.de
Fri Feb 26 01:07:23 PST 2010


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

* the syntax does not allow nesting:

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

Greetings,
Norbert



More information about the Digitalmars-d mailing list