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

is it reasonable to have a keyword for tail-recusive return? basically it means I'm writing a tail recursive function and give me compile error if it occurs at non-tai-recursive positions


Potentially yes. The question then arise: does it ever make sense not to add that keyword, and should you get linter/compiler warnings when it's not used? In which case, there will be little gain. My mind is not yet made up on this to be honest. I feel like it would be valuable, but it feels weird when I think about it some more.


I’m wondering in the Elm context if the compiler implemented this technique could it make a non stack safe recursion a compile time error?

And if it did, how restrictive would that be in practice?


I think it could yes if you had a keyword for adding the guarantee.

If you didn't have a keyword, then all functions would have to be made stack-safe, which is I think a lot to ask the users in some cases, especially when the language doesn't give you all the tools for it (I think CPS does not work for instance in Elm, currently investigating that a bit).

If you have a keyword, then it would be as restrictive as you'd want it to be I imagine?




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

Search: