I saw this explanation
Where first step is:
“start building a list of types, the first element is the type we’re
linearizing right now,”
however the result of this is:
// start with D1:
B with C with <D1>
I don’t get it. We start with D1 why is it in <>
at all? why is C with D1
and not D1 with B
. I don’t get whats going on there, can you please explain?
1
You will have to read the example a few times. I infer from the text elsewhere that the <> (diamonds) is a way to highlight the type we are looking at. So the type is
<D1>
D1
is defined as
class D1 extends B with C
Since D1
is lowest in the hierarchy, it is shown last.
B with C with <D1>
The rest of the steps are expansions of B
and C
, and the subsequent linearization.
Overall, I think the author’s example, in this case, is confusing. He is using Scala syntactic form to show a semantic process. While this can work quite well for demonstrating, for instance, the substitution principle, here it confounds syntax and semantics, instead of clarifying them.