From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jarmo Hurri Subject: Scala problem in Babel Date: Sun, 02 Apr 2017 15:39:40 +0300 Message-ID: <87r31bm19v.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuene-0001XJ-2T for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 08:40:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuenZ-0002zs-5r for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 08:40:06 -0400 Received: from [195.159.176.226] (port=46111 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuenY-0002zQ-V4 for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 08:40:01 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cuenK-0003xY-Bx for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 14:39:46 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Greetings. I am illustrating some basic syntactic differences between programming languages to some people. In order to do this I embedded a small Scala program into an Org file #+BEGIN_SRC scala :exports both object Fibonacci extends App { def fib (n : Int) : Int = { if (n == 1 || n == 2) n - 1 else fib (n - 1) + fib (n - 2) } println (fib (7)) } #+END_SRC This isn't in any way a correctly efficient way to (recursively) calculate numbers from the sequence, but this is only about syntactics for beginners, so I need to keep it very simple. Anyway, when I compile and run this code in Scala it works just fine: ------------------ [jarmo@localhost tmp]$ scalac test.scala [jarmo@localhost tmp]$ scala Fibonacci 8 ------------------ But C-c C-c in Org mode gives me a warning and no result: #+RESULTS: : /tmp/babel-6890GcO/scala-6890K2a:6: warning: Fibonacci$2 has a main method with parameter type Array[String], but Main.$anon$2.$anonfun$1.Fibonacci$2 will not be a runnable program. : Reason: companion contains its own main method, which means no static forwarder can be generated. : : object Fibonacci extends App : ^ : one warning found : () When I look at the temporary file I see that the code has been embedded in a wrapper defined in ob-scala.el. I guess it's the wrapper that messes up the execution of the code. What is the wrapper for? How am I supposed to use it? Jarmo