I have recently learnt about cake pattern and the differences between the uses of self =>
and self:T =>
(see here). The difference between these technicalities and real Scala code as remarked here continue to create me problems. For instance, see the following code snippet taken from the Inox project:
trait Trees
extends Expressions
with Constructors
with Extractors
with Types
with Definitions
with Printers
with TreeOps { self =>
...
val interpolator: Interpolator { val trees: Trees.this.type } = new {
protected val trees: Trees.this.type = Trees.this
} with Interpolator
...
}
In summary, the whole snippet does not make much sense to me (and it is a pattern frequently repeated in the code), let me explain:
- What is this syntax?
val interpolator: Interpolator { ... }
up to now I wrote val name: Type = value
, here there is no equal.
Trees.this.type
should be a type, but what type? It should be defined in Trees trait, and thethis
context which I bet is different from thetrait Trees
context (related to problem 1). I also looked on file Interpolators but there does not seem to be a type element.The greatest line is
protected val trees: Trees.this.type = Trees.this
.
Can anybody explain me what is going on here?