3 ms·
Given a call map(a, f) and a loop for _,e := range a { f(e); } both ought to have the same code size. Yes, map(a, f) will need to be inlined, but the for-loop i
by the-smug-one 5y ago
Given a call map(a, f) and a loop for _,e := range a { f(e); } both ought to have the same code size. Yes, map(a, f) will need to be inlined, but the for-loop is already inlined.
- creata 5y agoYou're right. To be clearer, the emphasis was on making it too easy to specialize: people don't just stop at maps and filters, they specialize everything, and that can have a significant impact on compilation times. For example, in Rust, people write stuff like [0] for the tiniest bit of syntax sugar, and they often don't bother extract out the non-generic part. [0]: https://news.ycombinator.com/item?id=24088407 https://news.ycombinator.com/item?id=24088407
- ben0x539 5y agoThe current idiomatic go style is to write your own for-loops for everything. Isn't that just manual specialization executed by the programmer rather than the compiler?