scala

Is there a method_missing in scala?

similar to the one in Ruby ...

Reverse AJAX (Comet) and Spring MVC vs. Scala/LIFT?

There is a demo by IBM that shows how easy Reverse AJAX can be used with DWR 2. On the other hand, Scala/LIFT comes with built-in Reverse AJAX capability. Question: Any experience if this works fine with Spring MVC? Question: If you'd start from scratch, what are the pros and cons for preferring Scala/LIFT over DWR/Spring MVC Question...

Scala equivalent of CSharp's Task.Factory.StartNew ?

In C# you can write: var alphaTask = Task.Factory.StartNew(() => {      return someWork(n); }); // ... do some other work, and later get the result from the task var res = alphaTask.Result; How would this simple construction look like in Scala? Thank you. ...

is the case of scala function parameters relevant?

Hi all, regarding the following scala code, functions m2a and m2b apparently differ only by the case of the parameter, ie abc vs Abc. This seems to make some difference in the result as per example below. When running it with a recent 2.8 compiler, it results in the following (I would have expected all true). Any insights would be apprec...

Change background of some ClanderItem item in Lift/Scala.

Hi, I'm trying use Lift and CalendarMonthView widget to build a appointment system. CalendarMonthView works with Lift very well, but I have a problem that could not change the style of some CalendarItem that displayed on the calendar. According to the API document, I use the following code to change the css class of certain CalendarIt...

Different output of matching on sequence in Scala 2.8

I'm a newbie to scala. I'm trying an example from the book "Programming Scala". The example can be get from here The output under Scala 2.8 RC6: List: List: List: I got the expected result under Scala 2.7.7: List: 1 3 23 90 List: 4 18 52 List: I don't know why it doesn't work on Scala 2.8. Please help me to figure it out. ...

Persistent data structures in Scala

Are all immutable data structures in Scala persistent? If not, which of them are and which not? What are the behavioural characteristics of those which are persistent? Also, how do they compare to the persistent data structures in Clojure? ...

Wait for an Actor to exit()

How do I wait for a Scala Actor to exit()? I set up two Actors in a unit test, and send a few messages to get them started. They send a few messages back and forth and eventually both call exit(). How do I make my unit test wait for both Actors to finish up before passing? ...

Has anyone had problems with scala code-completion in IDEA when using sbt?

I recently switched to sbt (which I completely dig) and as soon as I started to compile and run tests from sbt, code completion in IDEA seems to come and go... very strange. ...

Advantages of Scala's Type System

I am exploring Scala language. One claim I often hear is that Scala has a stronger type system than Java. By this I think what people mean is that: scalac rejects certain buggy programs which javac will compile happily only to cause a runtime error certain invariants can be encoded in a Scala program such that the compiler won't let th...

SQL syntax error with Derby and Circumflex ORM

I'm trying to use Circumflex ORM (as suggested on StackOverflow - here, here and here) to connect to a local (embedded) Apache Derby database over JDBC from a Scala project (built with simple build tool). I've followed the instructions carefully, but am having some interesting problems. Here's the driver and URL components of the cx.pro...

What is the Scala annotation to ensure a tail recursive function is optimized?

I think there is @tailrec annotation to ensure the compiler will optimize a tail recursive function. Do you just put it in front of the declaration? Does it also work if Scala is used in scripting mode (for instance using :load <file> under REPL)? ...

Scala actors on android

I tried using actors in a small scala (2.8) app on android (2.1) today and I keep getting a really weird error referencing sun.misc.Unsafe.throwException. I'm thinking that maybe the dalvik VM doesn't include this so Actors basically can't be used on android but I hope I'm wrong. Did anyone manage to get actors working on android? ...

Rationale for separate HTML template files in Scala webapps?

Everyone who's done any web application development in Scala knows that you can use any existing Java web framework, or you can use Lift. Something that all of these frameworks have in common is that they all require two or more files to generate a page: an HTML template of some kind, and one or more classes to provide associated logic...

Scala equivalent of CSharp’s Extension Methods ?

In C# you can write: using System.Numerics; namespace ExtensionTest { public static class MyExtensions { public static BigInteger Square(this BigInteger n) { return n * n; } static void Main(string[] args) { BigInteger two = new BigInteger(2); System.Console.WriteLine("The square of 2 is " + two.Squar...

[Scala] "can't existentially abstract over parameterized type..."

I was messing around with Scala 2.8 for fun and trying to define a pimp which adds an "as" method to type constructors, allowing to convert from one functor to another (please overlook the fact that I'm not necessarily dealing with functors here). So for instance, you could use it like this: val array:Array[T] val list:List[T] = array.a...

Scala / Lift: Set up hotdeploy through Eclipse?

How do I set up hotdeploy for Scala/Lift projects in Eclipse? Basically, I would like to be able to Set up a new project, from say lift-archetype-basic Launch jetty:run, either from some run-configuration or through terminal Be able to edit Scala files in Eclipse, Save/Auto compile Refresh the web-page in the browser and see the updat...

What does this piece of code mean in scala?

def func(arg: String => Int): Unit = { // body of function } I mean this fragment: String => Int ...

How to pass a raw type in Scala?

How can I pass a parameter to a Java method with a raw type in its method signature? My example API is as follows: class P<T> {} class Q { public void f(P p[]) {} } And my attempt to call it from Scala looks like this: val q = new Q() val p = new P() val p_array = Array(p) q.f(p_array) Which generates the following compiler e...

Scala, parametherised objects

Is this possible to get: object test[A](l: Int): List[A] = { ... } You know what i mean. Is that possible? ...