scala

Functional languages targeting the LLVM

Are there any languages that target the LLVM that: Are statically typed Use type inference Are functional (i.e. lambda expressions, closures, list primitives, list comprehensions, etc.) Have first class object-oriented features (inheritance, polymorphism, mixins, etc.) Have a sophisticated type system (generics, covariance and contrava...

Visibility of properties in scala class

I defined a property in the constructor of my class the following way: class Step(val message:String = "") When I try access to message value from Java code y get a visbility error. Why? ...

Modify iterator

I have a iterator (ite) created from a set (a): var a = Set(1,2,3,4,5) var ite = a.iterator If I remove 2 element of my set: a -= 2 Now, if I move iterator for all elements, I get all elements (2 element included). It's ok, but... How I can tell to iteratator to delete 2 element? ...

Parsing HTTP - Bytes.length != String.length

Hello, I consume HTTP via nio.SocketChannel, so I get chunks of data as Array[Byte]. I want to put these chunks into a parser and continue parsing after each chunk has been put. HTTP itself seems to use an ISO8859-Charset but the Payload/Body itself may be arbitrarily encoded: If the HTTP Content-Length specifies X bytes, the UTF8-deco...

Get name of class-attribute or class-function as String

Say i have the following class: class Person { @BeanProperty var firstName: String = _ } Is it possible to get the String representation of "firstName" in a type-safe way, by reflection or something? Or the String representation of the generated "getFirstName"-Function? It would be nice if it would somehow look like: val p = new...

static java bytecode optimizer (like proguard) with escape analysis?

Optimizations based on escape analysis is a planned feature for Proguard. In the meantime, are there any existing tools like proguard that already do optimizations which require escape analysis? ...

Possible to not use ID field but another column name? in Lift

I am connected to a oracle database from a scala/lift webapp. I have been able to successfully pull information from the database as I wished but am having one issue. For each table I want to access I am required to add an ID field so that the app will work with the trait IdPK. What mapper class or trait can I use to override this? I...

scala actor message definition

Do i need to define class for message i want to retrieve on a scala actor? i trying to get this up where am i wrong def act() { loop { react { case Meet => foundMeet = true ; goHome case Feromone(qty) if (foundMeet == true) => sender ! Feromone(qty+1); goHome }}} ...

Has anyone got the vim taglist plugin working with Scala?

I'm having trouble getting the taglist plugin working properly with Scala. I've installed the plugin and ctags and verified that it works properly with Java and C++. I then followed the instructions on this page (minus the Lift specific instructuions), but was nothing shows up in the taglist window when I open it while editing a Scala ...

scala REPL is slow on vista

I installed scala-2.8.0.RC3 by extracting the tgz file into my cygwin (vista) home directory. I made sure to set $PATH to scala-2.8.0.RC3/bin. I start the REPL by typing: $ scala Welcome to Scala version 2.8.0.RC3 (Java HotSpot(TM) Client VM, Java 1.6.0_20). Type in expressions to have them evaluated. Type :help for more information. ...

How to check whether a String fully matches a Regex in Scala?

Assume I have a Regex pattern I want to match many Strings to. val Digit = """\d""".r I just want to check whether a given String fully matches the Regex. What is a good and idiomatic way to do this in Scala? I know that I can pattern match on Regexes, but this is syntactically not very pleasing in this case, because I have no groups...

Calling Java vararg method from Scala with primitives

I have the following code in Java: public class JavaClass { public static void method( Object x ) { } public static void varargsMethod( Object... x ) { } } When I try and access it from Scala, object FooUser { JavaClass.method(true) JavaClass.varargsMethod(true) // <-- compile error } I get the following comp...

Using Scala and StringTemplate, how do I loop through a Map

I have my environment setup nicely using Scala, StringTemplate within the Google AppEngine. I am having trouble looping through a Map and getting it to display in the template. When I assign a simple List of just Strings to the template it works using: In Scala Servlet: var photos = List[String]() //... get photo url and title ......

example of using scala.collection.immutable.Set from java

Does anyone out there who's familiar with Scala know how I could use scala.collection.immutable.Set from Java? I can vaguely read the scaladoc, but am not sure how to call scala methods like "-" from java (I assume that I just need to include some scala .jar file in my classpath...?) ...

Packaging and Deploying Scala Applications

What is the simplest way to package a Scala application for use on a desktop PC? I'm guessing that would be in the form of a jar file. At the moment I'm using SBT to compile and run programs I'd be interested in solutions for machines that have Scala installed (and the library in their classpath), as well as those that only have Java. ...

can't run a scala script on Mac OS X

Running a scala script on Mac OS X results in the following error: Unable to establish connection to compilation daemon I found a page reporting the same problem: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=576568 To solve the problem, the page said: Can you please tell what does /etc/sysctl.d/bindv6only.conf contain...

What's the best way of accessing a DRb object (e.g. Ruby Queue) from Scala (and Java)?

I have built a variety of little scripts using Ruby's very simple Queue class, and share the Queue between Ruby and JRuby processes using DRb. It would be nice to be able to access these from Scala (and maybe Java) using JRuby. I've put together something Scala and the JSR-223 interface to access jruby-complete.jar. import javax.script...

Scala regex Named Capturing Groups

In scala.util.matching.Regex trait MatchData I see that there support for groupnames , I thought that this was related to (Regex Named Capturing Groups) But since Java does not support groupnames until version 7 as I understand it (ref), Scala version 2.8.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6. gives me this exception: scala>...

process csv in scala

I am using scala 2.7.7, and wanted to parse CSV file and store the data in SQLite database. I ended up using OpenCSV java library to parse the CSV file, and using sqlitejdbc library. Using these java libraries makes my scala code looks almost identical to that of Java code (sans semicolon and with val/var) As I am dealing with java ob...

Datatype-generic programming libraries for Scala

I'm looking for a Scala library allowing for datatype-generic programming (like Scrap Your Boilerplate, for example). A list of libraries with appropriate links and short descriptions for each one would be a perfect answer. ...