Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a nugget buried at the bottom of this: you will get different output for different kinds of for ... range or for i ... loops. You'd think these are equivalent:

        for i = range arr {
                sum += arr[i]
        }
        for _, c = range arr {
                sum += c
        }
... but the latter is 4 bytes shorter in x86. The compiler takes things literally.


Nice explanation, thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: