The Artima Developer Community
Sponsored Link

Programming in Scala Forum
Suggestion for Chapter 10

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ravi Mohan

Posts: 11
Nickname: ravim
Registered: Jan, 2003

Suggestion for Chapter 10 Posted: Feb 17, 2008 4:22 AM
Reply to this message Reply
Advertisement
I think linearization of traits should be explained *in terms of* existing examples (locking/logging or even hash cache/basebook) rather than create an abstract hierarchy with Class C having traits T1, T2 etc. (pages 206, 207).

Thus working out the linearization of


class Book(author: String, title: String)
extends BaseBook(author, title)
with Ordered[Book]
with HashScrambling
with HashCaching


val myBook = new Book ....


and then showing how a call on myBook.hash propagates up the linearized super classes should be a good way to explain how stackable modifications work (imo).

right now there is no *worked* example and everything is taken "on faith" as it were.

Also, there ought to be a clearer explanation of how linearization works rather than say

" The precise order of the linearization is described in the language specification. It is a little bit complicated ... "

Also,

"Then, whenever you call super inside one of
those classes, the invoked method is the next one ***up*** the chain."

"Up" is mildly confusing since the linearization is *represented* as a left to right comma separated list of class/trait names in the language specification.

Again a worked out example (vs class C traits t1, t2 etc) would make clear if "up" means moving left or right on the written down linearization.


Now coming to the actual explanation of linearization in page 207, the language is confusing.
e.g:
"The last part of the linearization of C is the linearization of class Sup." ---(1)

"last part" would seem to imply that this is (temporally) the last activity.


"This linearization is copied over without any changes."

huh? we just claimed that this was the "last" part. So is the copying a "last + 1"th activity?

"The second to last part is
the linearization of the first mixin, trait Trait1, but all classes that are al-
ready in the linearization of Sup are left out now,"

But I thought the linearization of Sup was the last actiity as per (1). So how are "all classes that are al-
ready in the linearization of Sup" available to "leave out"?

In short, I think this whole section needs a rewrite!


Regds,
Ravi

Topic: Could we have a chapter on unit testing please? Previous Topic   Next Topic Topic: Duplication in Chapter 8?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use