d optimization: delegates vs. mixin
bearophile
bearophileHUGS at lycos.com
Wed Oct 21 13:22:01 PDT 2009
zoli:
> Thank you. Could you provide a sample or a link ?
Silly D2 code:
import std.stdio: writeln;
void table(alias Mapper, T)(T[] arr) {
foreach (el; arr)
writeln(Mapper(el));
}
void main() {
table!((x){ return x * x;})([2, 3, 4]);
}
I don't like that code a lot, I'd like the D compiler to be smarter, so the programmer can avoid such silly tricks, and the programmer can program in a more functional style (where you use *functions*).
> Sorry, i know it's a d.learn topic...,
Yep. Better to ask such things there.
> Offtopic: Is it possible to alter the web interface of the news to change newsgroups during composition ?<
I don't know. Probably not.
Bye,
bearophile
More information about the Digitalmars-d
mailing list