2 ms·
But it also doesn’t mean you should not. Sometimes, the technique of returning a promise (“here’s something that can be converted to what you asked for, even th
by Someone 6y ago
But it also doesn’t mean you should not. Sometimes, the technique of returning a promise (“here’s something that can be converted to what you asked for, even though you didn’t tell yet exactly what you want”) is very useful.
A simple example is multiply-add. For your own types, you can have the compiler translate
a = b * c + d;
into
a = multiply_add(b, c, d);
that means you can use familiar notation and yet use faster/more accurate composite functions.
Stroustrup, in “the C++ Programming Language”, states he has seen a speed up of a factor of 30 using this ‘trick’ on matrix code.
He also advices against going over the top on it, though, so he agrees with “you can doesn’t imply you should”.
- cesaref 6y agoYeah, agreed, there's a time and a place for this stuff. The art of programming is knowing when to break the rules, similar to most artistic pursuits.