Why doesn't scalac (the Scala compiler) optimize tail recursion?
Code and compiler invocations that demonstrates this:
> cat foo.scala
class Foo {
def ifak(n: Int, acc: Int):Int = {
if (n == 1) acc
else ifak(n-1, n*acc)
}
}
> scalac foo.scala
> jd-gui Foo.class
import scala.ScalaObject;
public class Foo
implements S...
I've been converting some code from java to scala lately trying to teach myself the language.
Suppose we have this scala class:
class Person() {
var name:String = "joebob"
}
Now I want to access it from java so I can't use dot-notation like I would if I was in scala.
So I can get my var's contents by issuing:
person = Person.new(...
I'm trying to use the java jcommander library from Scala. The java JCommander class has multiple constructors:
public JCommander(Object object)
public JCommander(Object object, ResourceBundle bundle, String... args)
public JCommander(Object object, String... args)
I want to to call the first constructor that takes no var...
FSC recompiles my .scala files every time even there is no need - I can compile it twice without editing anything between attempts and it recompiles them!
For example, I have 2 files
Hello.scala
class Hello{
print("hello")
}
And Tokens.scala:
abstract class Token(val str: String, val start: Int, val end: Int)
{override def toSt...