background preloader

Scala

Facebook Twitter

Delimited Continuations. Scala's delimited continuations, introduced in version 2.8, can be used to implement all sorts of interesting control constructs.

Delimited Continuations

This is a very long blog post. It took me quite a while to get my head around Scala's reset and shift operators. To help others hopefully avoid the stumbling blocks I encountered, I have tried here to start with the basics and build up from there in some detail. If you want a shorter explanation, see the Resources section at the end of this post for pointers to some other blog entries that are more succinct. Contents Mechanics In order to use Scala's delimited continuations, you must use version 2.8, and you must use the continuations (or CPS) compiler plugin. In your source code, you must import the appropriate continuations elements, which you can do most simply by using a wildcard to import everything: import scala.util.continuations If you forget to do the import you will get an error message similar to this: <console>:6: error: not found: value reset reset { ^

Scala Functions vs Methods. Scala has both functions and methods.

Scala Functions vs Methods

Most of the time we can ignore this distinction, but sometimes we have to deal with the fact that they are not quite the same thing. In my Scala Syntax Primer I mention that I use the terms method and function interchangeably in the discussion. This is a simplification. In many situations, you can ignore the difference between functions and methods and just think of them as the same thing, but occasionally you may run into a situation in which the difference matters. This is analogous to how most of us treat mass and weight. In contrast to Kg vs pounds, you are rather more likely to come across a situation in which the distinction between Scala functions and methods is important than you are to be walking on the surface of the moon.

A Scala method, as in Java, is a part of a class. A function in Scala is a complete object. Let's look at some details of this mechanism. Compile that file with scalac and list the resulting files. Java to Scala with the Help of Experts. Java to Scala with the Help of Experts Many leading experts in the industry have recognised the importance of Scala and are enthusiastic to help others appreciate the language.

Java to Scala with the Help of Experts

They have written excellent reviews and teaching materials that range from broad evaluations of the language to detailed cook-books on how to use the scala language. Each one comes from a different programming background and quite likely you will find one like your own. At times we all get stuck on learning a specific topic, just don't seem to get it. We need to take a look from a fresh point of view to gain the insight we need. There are lots of other experts in the Scala community and Scala user groups that are there ready to help you too. There is a growing list of books on programming in Scala too. If you find other material helpful as you moved from Java to Scala or from other languages please let us know so we can share it with other first time Scala programmers.

The Seductions of Scala Bill Venners Artima.

Design Patterns

Type System. Actors and Concurrency.