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

Tcl added this relatively recently. They use the "tailcall" command, which immediately replaces the stack frame of the current function with one for the new function. If I recall correctly, it doesn't do any checks for whether or not the call is actually a tail-call, so if you do something like

    return [expr [tailcall foo] + 1]
the return and expr simply never get executed, producing incorrect results (which I guess is slightly better than a potential stack overflow, since even the most basic of tests will pick up on the missing +1).


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

Search: