actors with daemon-style semantics
Scala 2.8 was announced yesterday. They highlight among other things "Enhanced actors". What does "actors with daemon-style semantics" mean and where can I find more about that? ...
Scala 2.8 was announced yesterday. They highlight among other things "Enhanced actors". What does "actors with daemon-style semantics" mean and where can I find more about that? ...
I wrote a simulation of the Ring network topology in Scala (source here) (Scala 2.8 RC7) and Clojure (source here) (Clojure 1.1) for a comparison of Actors and Agents. While the Scala version shows almost constant message exchange rate as I increase the number of nodes in network from 100 to 1000000, the Clojure version shows message r...
There's an open source program called CIMCheck (http://wiki.cimtool.org/CIMCheck.html) that is supposed to be a command line utility which is run with command java -jar cimcheck.jar [option...] argument1 argument2 When I downloaded the source code, there was no .jar files at all, only a couple of .scala files and others. So I hav...
I'm playing with RemoteActors. Now I wonder, what happens if I shut down an RemoteActor. The actor was made available with RemoteActor.alive and RemoteActor.register. I can't find the inverse of either of both: alive and register. How do I properly shut down an RemoteActor? Update To make it more obvious, I made a 'small' example. Ne...
In 2.7 I could do the following: val lazyM: Map[_, _] = map.projection.mapElements(v => expCalc(v)) //MAP VIEW I can't find a way of doing this in 2.8 and actually ending up with a map: val m: Map[_, _] = map.view.map(kv => kv._1 -> expCalc(kv._2)).toMap //STRICT This seems like a significant loss of functionality and therefore I a...
I get compile errors when compiling valid code against a Java model enhanced with JDO. I am confused at the errors because there is no direct usage of the package private static member interfaces in question from Scala. I understand Scala doesn't support using such interfaces from Scala code, but I am confused that the Scala compiler com...
I would like to be able to use Spring using setter injection into Scala components. Unfortunately, Scala's native setters are named differently from than the JavaBeans standard, foo_= rather than setFoo. Scala does provide a couple of workarounds for this, annotations which force the creation of JavaBeans setters/getters as well as nat...
I'm trying get cross compiling between 2.7.7 and 2.8.0. The package is included, this works just fine in 2.7.7. Here's the code: package bizondemand.utils { package logging { import _root_.org.slf4j.LoggerFactory /**This code copied and pasted from http://johlrogge.wordpress.com/2009/06/27/loggingtools-in-scala/ * */ I keep get...
I was at a Java conference on Scala the other day and the speaker referred to 'full powered closures'. I am having a hard time nailing down a definition that makes sense to me. I have read the wiki page on closures but it really didn't answer it for me. Can someone help me with a clear cut definition? Maybe even include a simple examp...
Hi all, I'm attempting to calculate the average color of an image in Scala, where "average" is defined as the redSum/numpixels, greenSum/numpixels, blueSum/numpixels . Here is the code I am using to calculate the average color in a rectangular region of an image (the Raster). // A raster is an abstraction of a piece of an image and th...
I'm trying to create an instance of a trait using this method val inst = new Object with MyTrait This works well, but I'd like to move this creation in to a generator function, ie. object Creator { def create[T] : T = new Object with T } I'm obviously going to need the manifest to somehow fix the type erasure problems, but before...
I'm trying to learn Scala and tried to write a sequence comprehension that extracts unigrams, bigrams and trigrams from a sequence. E.g., [1,2,3,4] should be transformed to (not Scala syntax) [1; _,1; _,_,1; 2; 1,2; _,1,2; 3; 2,3; 1,2,3; 4; 3,4; 2,3,4] In Scala 2.8, I tried the following: def trigrams(tokens : Seq[T]) = { var t1 : ...
I'm trying to use various scala implementations of C#-like yield return (i.e. link text) with "for" -constructions such as: private def permutations[T](s: Vector[T]) = { def swap(i: Int, j: Int) { val tmp = s(i) s.set(i, s.get(j)) s.set(j, tmp) } iterator[Vector[T]] { def generate(left: Int, right: Int): Unit @cps...
Hey, I asked myself this question a couple of times and came up with a solution for that feels very dirty. Maybe you can give me any advice since I think this is a basic problem for every DSL written in Scala. I want to have a hierarchical structure of nested objects without adding any extra syntax. Specs is a good example for this: M...
In the Scala 2.8 reference, section 5.3.3 page 69 (77 in the pdf) the following paragraph appear: Assume a trait D defines some aspect of an instance x of type C (i.e. D is a base class of C). Then the actual supertype of D in x is the compound type consisting of all the base classes in L(C) that succeed D. What does the ...
I'm trying to inject some Scala code into my existing Java app. (So, being said, I want some more fun). I create a singleton stuff in Scala ScalaPower.scala package org.fun class ScalaPower object ScalaPower{ def showMyPower(time:Int) = { (0 to time-1).mkString(", ") } } Now, inside OldJava.java ...
Given a simple generic class: class EqualsQuestion[T]( val value :T ) it seems reasonable that the following code would resolve to "false": val a = new EqualsQuestion[Int]( 5 ) val b = new EqualsQuestion[Long]( 5 ) a == b (Yes, it's a contrived example. In my real code I wanted '==' to fail if the type parameters are different, re...
I'm using Scala to do typesafe JPA2 Criteria Queries. Therefore i have a Java MetaModel Class (the only Java in my code, the rest is Scala -> pure Scala problem), which holds my model attributes: @StaticMetamodel(User.class) public class User_ { public static volatile SingularAttribute<User, Long> id; public static volatile Singula...
I try to define the Reader monad with scalaz like this: import scalaz._ import Scalaz._ final class Reader[E,A](private[Reader] val runReader: E => A) object Reader { def apply[E,A](f: E => A) = new Reader[E,A](f) def env[E]: Reader[E,E] = Reader(identity _) implicit def ReaderMonad[E] = new Monad[PartialApply1Of2[Reader,E]#App...
This question is so stupid... Anyway, i just can't find the right information, because every Scala-constructor example class i see works with at least one parameter. I want to have this class translated from Java to Scala: public class SubscriptionConverter extends Converter { public SubscriptionConverter() { Context ctx = new In...