The sequence of template statements may be prefixed with a formal parameter definition and an arrow, e.g. x =>, or x:T =>. If a formal parameter is given, it can be used as an alias for the reference this throughout the body of the template.

I think you might be conflating two different concepts. Let me see if I can answer your question… In essence, a self type does two things:

Requires classes extending the trait to be of a certain type.

Let’s take this example…

trait Database {
impl: DbImpl =>
....
}

In the example above, you can only extend Database if the class that extends it is an instance of DbImpl. If you tried to do anything else the compiler would yell at you.

Lets you reference members of the subtype

Normally, when you’re writing a trait, you can only access the other things you define in the trait. When you define a self type you can also access things defined in the class that defines the trait. For example:

Back to the SLS quote

Back to the bit you quoted from the SLS…

I believe the crux of what you saw means that the following is possible…

trait Database {
this: DbImpl =>
}

Normally if you use this in a trait I believe you’re referencing the trait itself. The use of this construct means that inside the trait the this keyword is changed to reference the DbImpl mixing in the trait, not the trait itself.

Just re-read your original question and realized I may have explained some stuff you already understood… hehe.

The reason being able to alias this is useful is simply for convenience purposes as far as I know. You can use other identifiers if you want to reference the class you’re mixing in as I did in my example above. =)