Denis Koroskin írta:
On Tue, 01 Dec 2009 17:02:40 +0300, Nick Sabalausky <a...@a.a> wrote:
"Gzp" <ga...@freemail.hu> wrote in message
news:hf2k9a$2l5...@digitalmars.com...
The compiler also should provide readably output of the generated code.
I'm not sure if this is what you mean, but I definitely want a compiler
switch that outputs the resulting D code after all the mixins and such
are
applied.
Yes this is what I've meant and also a way to document the generated
codes in a more readable form.
Ex. for a matrix (planned to) have multiple additions depending on the
matrix representation and each have a different property (like
performance) that the user should be aware of. The actual functions the
user calls are generated by mixins and it's quite difficult to find out
what is called exactly.
So from a documentation view it'd be great to document the
(auto)generated code.
FWIW, Descent already capable of doing this:
http://www.youtube.com/watch?v=oAhrFQVnsrY
It looks great to develop the library, but as a user of a library most
certainly I'm not interested how the code is expanded I just want to now
what function/class to use and what parameters it requires. (Though I
really liked the idea).
ex:
package template DefineUnary(string tName, string tFunction) {
const char[] code = "void " ~ tName ~ "(T)( ref T p ) { " ~
"UnaryOperation!(\""~ tFunction~ "\").inPlace( p
); }" ~
"void " ~ tName ~ "(T1, T2)( const T1 p1, ref T2
p2 ) { " ~
"UnaryOperation!(\""~ tFunction~ "\").copy( p1,p2
); }";
}
mixin( DefineUnary!("neg", "-a" ).code );
mixin( DefineUnary!("twice", "2*a" ).code );
mixin( DefineUnary!("triple", "3*a" ).code );
It's quite hard to find out what is the function actually. Not only the
parameters but the function name is not trivial at all.
Note: There might be better solutions for this.
Gzp