Why are effect-less functions executed?

Posted by user828584 on Programmers See other posts from Programmers or by user828584
Published on 2012-06-20T17:56:09Z Indexed on 2012/06/21 3:25 UTC
Read the original article Hit count: 222

All the languages I know of would execute something like:

i = 0
while i < 100000000
    i += 1

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

edit: I mean inside a function which is called

function main(){
    useless()
}
function useless(){
    i = 0
    while i < 100000000
        i += 1
}

© Programmers or respective owner

Related posts about programming-languages

Related posts about language-agnostic