4 ms·
Could you elaborate on Scala's TCO support? I was under the impression that only self-tail calls are eliminated and only if the stack trace would be provably un
by silentOpen 13y ago
Could you elaborate on Scala's TCO support? I was under the impression that only self-tail calls are eliminated and only if the stack trace would be provably unused. Doesn't the JVM require stack traces? Can you use CPS in Scala?
I see now that Scala can encode GADTs in case classes. What mechanism is available to encode polymorphic variants? Particularly, I am interested in writing matches over unions of polymorphic variant types.
I disagree that 2 and 3 are the same (structural module subtyping, nesting, inclusion differs from applicative functors). I believe you can achieve mixins with OCaml through the object system but it's not clear to me that this addresses functor signature checking.
Another Scala bonus:
5. Objects can implicitly be null.
- seanmcdirmid 13y agoScala has TCO support, but maybe not as advanced as Ocaml, being limited by the JVM and all. CPS is heavily used in scala these days, as far as I can tell by reading Ingo Meir's work. I was confused about polymorphic variants. Scala doesn't seem to have that. I did a lot of work with units (dr. scheme-style functors) before, and when I moved to scala for my postdoc, I found all my patterns expressible using mixins and nominal types...I didn't miss the modules (1st class or otherwise). Scala has a non-null-ability option, but most programmers I think would find null damn convenient.
- unhappy_dino 13y agoNew account, but old comment because I have been shadow-banned a few minutes ago: You need to pick a decent runtime which supports proper tail calls and everything just works fine. I consider the sad fact that scalac tries to do TCO too an ugly hack necessary to reduce the pain of poor VM implementations. Regarding 5.: null is a legacy feature for Java interop. It's not commonly used in Scala. If you decide to use null in Scala anyway, you will need to have a really good reason. Otherwise people will feel that you just spit in their face.