jvm-languages

How are coroutines implemented in JVM langs without JVM support?

回眸只為那壹抹淺笑 提交于 2019-11-28 16:37:38
问题 This question came up after reading the Loom proposal, which describes an approach of implementing coroutines in the Java programming language. Particularly this proposal says that to implement this feature in the language, additional JVM support will be required. As I understand it there are already several languages on the JVM that have coroutines as part of their feature set such as Kotlin and Scala. So how is this feature implemented without additional support and can it be implemented

Haskell on JVM?

…衆ロ難τιáo~ 提交于 2019-11-28 16:08:01
问题 I'm wondering if there is some way to make Haskell run on the JVM (compiled or interpreted)? There exists JHaskell on Sourceforge but this one seems to be empty and dead. GHC uses LLVM as compiler backend. Would it be a good idea or possible to compile LLVM to Java bytecode? Or maybe use a different compiler backend? 回答1: You may want to investigate Frege. Quoting from that page: "Frege is a non-strict, pure functional programming language in the spirit of Haskell." "Frege programs are

Create a JVM programming language

二次信任 提交于 2019-11-28 13:11:42
问题 I have created a compiler in C (using lex & bison) for a dynamic typed programming language that supports loops, functions declarations inside functions, recursive calls etc. I also created a virtual machine that runs the intermediate code created by the compiler. I was now thinking instead of compiling to my own intermediate code, compile it to java byte code. I saw that the question about creating a JVM language has already been asked but I don't find the answer very informative. So here

Why can't tail calls be optimized in JVM-based Lisps?

时光怂恿深爱的人放手 提交于 2019-11-28 05:24:56
Main question: I view the most significant application of tail call optimization (TCO) as a translation of a recursive call into a loop (in cases in which the recursive call has a certain form). More precisely, when translated into a machine language, this would usually be translation into some sort of series of jumps. Some Common Lisp and Scheme compilers that compile to native code (e.g. SBCL) can identify tail-recursive code and perform this translation. JVM-based Lisps such as Clojure and ABCL have trouble doing this. What is it about the JVM as a machine that prevents or makes this

Using partial functions in Scala - how does it work?

爷,独闯天下 提交于 2019-11-27 10:00:41
I'm new to Scala, I'm using 2.9.1, and I'm trying to get my head around how to use partial functions. I have a basic understanding of curried functions, and I know that partial functions are kind of like curried functions where they are only 2nary or some such. As you can tell I'm a bit green at this. It does seem that in certain cases like XML filtering, being able to partial functions would be highly advantageous, so I'm hoping get a better understanding of how to use them. I have a function that uses the RewriteRule structure, but I need it to work with two arguments, whereas the

Why can't tail calls be optimized in JVM-based Lisps?

守給你的承諾、 提交于 2019-11-27 05:33:45
问题 Main question: I view the most significant application of tail call optimization (TCO) as a translation of a recursive call into a loop (in cases in which the recursive call has a certain form). More precisely, when translated into a machine language, this would usually be translation into some sort of series of jumps. Some Common Lisp and Scheme compilers that compile to native code (e.g. SBCL) can identify tail-recursive code and perform this translation. JVM-based Lisps such as Clojure and

Using partial functions in Scala - how does it work?

丶灬走出姿态 提交于 2019-11-27 04:01:29
问题 I'm new to Scala, I'm using 2.9.1, and I'm trying to get my head around how to use partial functions. I have a basic understanding of curried functions, and I know that partial functions are kind of like curried functions where they are only 2nary or some such. As you can tell I'm a bit green at this. It does seem that in certain cases like XML filtering, being able to partial functions would be highly advantageous, so I'm hoping get a better understanding of how to use them. I have a