Edited, memorised or added to reading list

on 11-Aug-2014 (Mon)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

#scala
Types and behavior of objects are described by classes and traits.
statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Introduction - Scala Documentation
ing patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. Scala is object-oriented Scala is a pure object-oriented language in the sense that every value is an object. <span>Types and behavior of objects are described by classes and traits. Classes are extended by subclassing and a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance. Scala is functional Scala is also a functional lang




#scala
Scala’s case classes and its built-in support for pattern matching model algebraic types used in many functional programming languages.
statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Introduction - Scala Documentation
cala is also a functional language in the sense that every function is a value. Scala provides a lightweight syntax for defining anonymous functions, it supports higher-order functions, it allows functions to be nested, and supports currying. <span>Scala’s case classes and its built-in support for pattern matching model algebraic types used in many functional programming languages. Furthermore, Scala’s notion of pattern matching naturally extends to the processing of XML data with the help of right-ignoring sequence patterns. In this context, sequence comprehension




#scala
In Scala, classes are parameterized with values (the constructor parameters) and with types (if classes are generic).
statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Abstract Types - Scala Documentation
<span>In Scala, classes are parameterized with values (the constructor parameters) and with types (if classes are generic). For reasons of regularity, it is not only possible to have values as object members; types along with values are members of objects. Furthermore, both forms of members can be concrete an




#scala
trait Buffer {
  type T
  val element: T
}

Abstract types are types whose identity is not precisely known. In the example above, we only know that each object of class Buffer has a type member T, but the definition of class Buffer does not reveal to what concrete type the member type T corresponds. Like value definitions, we can override type definitions in subclasses. This allows us to reveal more information about an abstract type by tightening the type bound (which describes possible concrete instantiations of the abstract type).

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Abstract Types - Scala Documentation
s; types along with values are members of objects. Furthermore, both forms of members can be concrete and abstract. Here is an example which defines both a deferred value definition and an abstract type definition as members of class Buffer. <span>trait Buffer { type T val element: T } Abstract types are types whose identity is not precisely known. In the example above, we only know that each object of class Buffer has a type member T, but the definition of class Buffer does not reveal to what concrete type the member type T corresponds. Like value definitions, we can override type definitions in subclasses. This allows us to reveal more information about an abstract type by tightening the type bound (which describes possible concrete instantiations of the abstract type). In the following program we derive a class SeqBuffer which allows us to store only sequences in the buffer by stating that type T has to be a subtype of Seq[U] for a new abstract type U:




#scala

In the following program we derive a class SeqBuffer which allows us to store only sequences in the buffer by stating that type T has to be a subtype of Seq[U] for a new abstract type U:


trait Buffer {
  type T
  val element: T
}

abstract class SeqBuffer extends Buffer {
  type U
  type T <: Seq[U]
  def length = element.length
}

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Abstract Types - Scala Documentation
s. Like value definitions, we can override type definitions in subclasses. This allows us to reveal more information about an abstract type by tightening the type bound (which describes possible concrete instantiations of the abstract type). <span>In the following program we derive a class SeqBuffer which allows us to store only sequences in the buffer by stating that type T has to be a subtype of Seq[U] for a new abstract type U: abstract class SeqBuffer extends Buffer { type U type T <: Seq[U] def length = element.length } Traits or classes with abstract type members are often used in combination with anonymous class instantiations. To illustrate this, we now look at a program which deals with a sequence b




#scala

Traits or classes with abstract type members are often used in combination with anonymous class instantiations. To illustrate this, we now look at a program which deals with a sequence buffer that refers to a list of integers:



trait Buffer {
  type T
  val element: T
}

abstract class SeqBuffer extends Buffer {
  type U
  type T <: Seq[U]
  def length = element.length
}

abstract class IntSeqBuffer extends SeqBuffer {
  type U = Int
}

object AbstractTypeTest1 extends App {
  def newIntSeqBuf(elem1: Int, elem2: Int): IntSeqBuffer =
    new IntSeqBuffer {
         type T = List[U]
         val element = List(elem1, elem2)
       }
  val buf = newIntSeqBuf(7, 8)
  println("length = " + buf.length)
  println("content = " + buf.element)
}

The return type of method newIntSeqBuf refers to a specialization of trait Buffer in which type Uis now equivalent to Int. We have a similar type alias in the anonymous class instantiation within the body of method newIntSeqBuf. Here we create a new instance of IntSeqBuffer in which type

...
statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Abstract Types - Scala Documentation
which allows us to store only sequences in the buffer by stating that type T has to be a subtype of Seq[U] for a new abstract type U: abstract class SeqBuffer extends Buffer { type U type T <: Seq[U] def length = element.length } <span>Traits or classes with abstract type members are often used in combination with anonymous class instantiations. To illustrate this, we now look at a program which deals with a sequence buffer that refers to a list of integers: abstract class IntSeqBuffer extends SeqBuffer { type U = Int } object AbstractTypeTest1 extends App { def newIntSeqBuf(elem1: Int, elem2: Int): IntSeqBuffer = new IntSeqBuffer { type T = List[U] val element = List(elem1, elem2) } val buf = newIntSeqBuf(7, 8) println("length = " + buf.length) println("content = " + buf.element) } The return type of method newIntSeqBuf refers to a specialization of trait Buffer in which type U is now equivalent to Int. We have a similar type alias in the anonymous class instantiat




#scala
A simple annotation clause has the form @C or @C(a1, .., an). Here, C is a constructor of a class C, which must conform to the class scala.Annotation. All given constructor arguments a1, .., an must be constant expressions (i.e., expressions on numeral literals, strings, class literals, Java enumerations and one-dimensional arrays of them).
statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Annotations - Scala Documentation
Annotations associate meta-information with definitions. <span>A simple annotation clause has the form @C or @C(a1, .., an). Here, C is a constructor of a class C, which must conform to the class scala.Annotation. All given constructor arguments a1, .., an must be constant expressions (i.e., expressions on numeral literals, strings, class literals, Java enumerations and one-dimensional arrays of them). An annotation clause applies to the first definition or declaration following it. More than one annotation clause may precede a definition and declaration. The order in which these claus




#scala
An annotation clause applies to the first definition or declaration following it. More than one annotation clause may precede a definition and declaration. The order in which these clauses are given does not matter.
statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

Annotations - Scala Documentation
which must conform to the class scala.Annotation. All given constructor arguments a1, .., an must be constant expressions (i.e., expressions on numeral literals, strings, class literals, Java enumerations and one-dimensional arrays of them). <span>An annotation clause applies to the first definition or declaration following it. More than one annotation clause may precede a definition and declaration. The order in which these clauses are given does not matter. The meaning of annotation clauses is implementation-dependent. On the Java platform, the following Scala annotations have a standard meaning. ScalaJavascala.SerialVersionUIDserialVersio