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

I think the CLR team was able to learn from some of the JVM's shortcomings; this limitation is one example. .NET IL has the TAIL. instruction prefix that allows tail calls. It can be prepended to any call instruction outside of an exception handling block.

There's also the JMP instruction, which is similar and allows the current method's arguments to be passed to another function, discarding the current stack frame and returning to the current method's caller.



Even more interesting is that C# and VB.NET, the two main languages targeting the CLR, do not make use of it. Before posting this though, I did a quick search to make sure they hadn't turned around and implemented it for C# 4 or something, and found this link:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeed...

Apparently there are some performance issues with the TAIL IL instruction, though I wonder if it's really as slow as pushing a new frame on the call stack.




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

Search: