Using a macro for a function signature
pineapple via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 5 04:35:24 PDT 2016
If I have a common function signature I'm using throughout my
code, and I feel like there should be a way to condense it using
a macro. The intuitive method isn't working, but this seems like
something D would be able to do. What've I got wrong in this
example?
alias somelongsignature = int(in int x);
int examplefunc0(in int x){
return x * 2;
}
somelongsignature testfunc0 = examplefunc1;
somelongsignature testfunc1 = somelongsignature {return x + 3};
public void main(){
import std.stdio;
writeln(testfunc0(5)); // Should output 10
writeln(testfunc1(5)); // Should output 8
}
Thanks!
More information about the Digitalmars-d-learn
mailing list