On Saturday, 7 December 2013 at 18:13:06 UTC, bearophile wrote:
MattCoder:
Maybe It's just me, but on the example above I don't see too
much improvement:
1 word off ("return"), and "=>" instead of brackets.
In D:
Point move(in int dx, in int dy) pure nothrow {
return Point(X + dx, Y + dy);
}
Point move(in int dx, in int dy) pure nothrow => Point(X + dx,
Y + dy);
It saves you almost 10% of typing, and makes more visible that
move is an expression. If you use UFCS chains a lot, many
functions become small and they sometimes contain just an
expression.
Well,I think you have a point here.
Currently in D you can write:
enum move = (in int dx, in int dy) pure nothrow => Point(X +
dx, Y + dy);
Interesting, I didn't know about this. Thanks for the tip.
Matheus.