2 ms·
Special-casing (same-length) zip and iteration+count might make sense for an imperative language which doesn’t want to go down the rabbit hole of implementing e
by avgcorrection 4y ago
Special-casing (same-length) zip and iteration+count might make sense for an imperative language which doesn’t want to go down the rabbit hole of implementing efficient, lazy iterators. It doesn’t make sense in a language where you want the flexibility of switching between (as in: compiling to) serial loops and paralell code, but it makes sense for a language which leans more towards what-you-see-is-what-you-get rather than sufficiently-smart-compiler.
- noobermin 4y agoTbh, there are limits to how much any language that does "wysiwyg" compilation that would have for loops. For example, any "for" loop can be a "while" loop in asm, the one optimization is you can use the index registers as long as the number of arrays is less than the number of index registers you have. If it is more, which the language does not constrain of course, you just go back to a loop with memory locations for pointers. But of course, in that case then, you must have a "smart compiler" that can decide that which case it is and thus compile to the right code. That said, this likely will be an esoteric case on most modern machines (like x86_64 has 16 regs that can be used for indexes) and I doubt people want to use this for like avr.