3 ms·
>Isn't this an optimisation that could/should be handled by the compiler (JIT evaluation or something like that)? Interesting question, which i also asked myse
by stiGGG 8y ago
>Isn't this an optimisation that could/should be handled by the compiler (JIT evaluation or something like that)?
Interesting question, which i also asked myself every once in a while, but unfortunately couldn't find a clear answer so far. Maybe someone with deeper understanding of swiftc or aot compilers in general here could clarify?
ps.: To give my reply a meaning. JIT optimization in particular can not happen here, because swift is an ahead of time compiled language, which means the compiler produces machine code which runs directly on your CPU. JIT is a thing for languages which run in a virtual machine (e.g. Java or C#) or an interpreter (e.g. Javascript).
- pseudonom- 8y agoWhen the compiler handles this, it is usually called "automatic deforestation". One technique for this (that Haskell's compiler implements) is "stream fusion". A brief overview of stream fusion is given at https://stackoverflow.com/questions/578063/what-is-haskells-stream-fusion https://stackoverflow.com/questions/578063/what-is-haskells-... and a lengthier paper is at http://fun.cs.tufts.edu/stream-fusion.pdf http://fun.cs.tufts.edu/stream-fusion.pdf.