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

This is correct. @tailrec will simply cause a compile failure if the compiler DOESN’T optimize the function, but the compiler does still optimize tail recursion without the annotation.

It’s a weird but helpful annotation. For example, Scala won’t optimize methods that can be overridden (non-final and public/protected), which is easy to forget. So the annotation is a nice check/confirmation that the compiler is doing what you expect.



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

Search: