Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualslicer4ever

Posted 02 November 2013 - 06:57 AM

why is 

while(running)  
replaced with  
void loop() {
...
if(running) { loop() } 

}
shouldn't that cause a Stack Overflow?


tail-recursion, since the function doesn't return meaningful data, the compiler effectively turns it back into a loop.

edit: note that with no optimizations on, the compiler won't do this, and you'll get a overflow crash.

#2slicer4ever

Posted 02 November 2013 - 06:26 AM

why is 

while(running)  
replaced with  
void loop() {
...
if(running) { loop() } 

}
shouldn't that cause a Stack Overflow?


tail-recursion, since the function doesn't return meaningful data, the compiler effectively turns it back into a loop.

#1slicer4ever

Posted 02 November 2013 - 06:25 AM

why is 

while(running)  
replaced with  
void loop() {
...
if(running) { loop() } 

}
shouldn't that cause a Stack Overflow?


tail-recursion, since the function doesn't return, the compiler effectively turns it back into a loop.

PARTNERS