3 ms·
> due to the language's embarrassing lack of TCO TCO is a runtime property, not a language property. Anyway, you have clearly not been doing your research and
by happy_dino 13y ago
> due to the language's embarrassing lack of TCO
TCO is a runtime property, not a language property.
Anyway, you have clearly not been doing your research and its not my job to do it for you.
Bye.
- anonymoushn 13y agoThis comment is hilarious. I guess I can now spend the rest of my life searching for the super-performant yet somehow extremely obscure JVM implementation with OS threads, green threads, and TCO. Edit: I am still seeking the legendary JVM implementation with TCO. I guess the argument is something like, oh well at some point in the future some JVM could conceivably have that feature, therefor it is wrong to say that Scala does not have it! Rather than writing code that assumes Scala is a complete joke of a functional language, one could simply write the code the natural way, verify that it compiles, and then wait until a JVM with TCO exists, so that it will stop crashing! In the mean time, one can enjoy the entertainment provided by Scala's inability to compile shift in an if statement without an else clause. Truly I am writing code exactly as I would if(it_was_synchronous) else { cpsunit }. I feel as though you told me reset and shift, although you did not. So thanks for that!
- happy_dino 13y ago> I am still seeking the legendary JVM implementation with TCO. scala> :paste // Entering paste mode (ctrl-D to finish) object TCO extends App { def stackSize = Thread.currentThread.getStackTrace.length def printStackSizeMessageOutside() = println(s"$stackSize stackframes outside of the mutually recursive calls") def printStackSizeMessageInside() = println(s"$stackSize stackframes inside the mutually recursive calls") def mutuallyRecursiveAdd1(a: Long, b: Long): Long = if (b == 0) { printStackSizeMessageInside() a } else mutuallyRecursiveAdd2(a+1, b-1) def mutuallyRecursiveAdd2(a: Long, b: Long): Long = if (b == 0) { printStackSizeMessageInside() a } else mutuallyRecursiveAdd1(a+1, b-1) printStackSizeMessageOutside() mutuallyRecursiveAdd1(23, 10000000) } // Exiting paste mode, now interpreting. defined object TCO scala> TCO main null We have 29 stackframes outside of the mutually recursive calls We have 30 stackframes inside the mutually recursive calls
- anonymoushn 13y agoSweet, where do I download it/which obscure flag to I pass to enable it? 27 stackframes outside of the mutually recursive calls java.lang.StackOverflowError at TCO$.mutuallyRecursiveAdd2(<console>:22) Oddly, your Thread.currentThread.getStackTrace.length seems to return strings like "We have 30". Mine is returning an Int over here.
- happy_dino 13y agoAh right. I refactored the messages a bit and didn't completely update the post to mirror that.
- anonymoushn 13y agoI am still very interested in learning about the runtime you are using :) After a significant amount of effort (googling for stuff about scala, JVMs, and TCO mostly gets hits with people complaining about their code not working) I discovered something called Avian, which I can try out soon. I still think it is a bit weird to spend time engaging with a stranger who wants to know something very simple, but to expect the stranger to dig around for it for a few hours instead of telling him.
- happy_dino 13y agoAs a general policy, if I spend time explaining things I require people to do some homework on their own. This way people who are lazy, whose interest is just strong enough to make ridiculous claims and complaints but don't actually care about the topic at hand, don't get things for free. I protect my investment and everyone wins.