Scala by Example - trait type parameter with context bounds mistake?

Up vote 2 down vote favorite share g+ share fb share tw.

Reading the Scala by Example book and there is this example when Martin explains type bounds on page 54: trait SetA Changing the trait keyword to abstract class or changing the view bound to type bound helps. Is this a mistake in the book? Scala view trait bound link|improve this question asked Dec 20 '11 at 13:30noncom5819 95% accept rate.

2 there was a change in the spec after "Scala by Example" was written. See this discussion – Paolo Falabella Dec 20 '11 at 13:38 Thanks for pointing out! However I think that it is not good that complexity of implementation influences the language.

There is no logical explanation of why traits may not have upper bounds. – noncom Dec 20 '11 at 14:04 1 Traits can have upper bounds. They cannot have context and view bounds, because these are constructor parameters, and traits can't have constructor parameters.

– Daniel C. Sobral Dec 20 '11 at 14:17 Thank you, Daniel, yes it appears to be that these constructions are merely syntactic sugar and the explanation lies in the real underlaying language syntax. However, I am curious now, could you please explain or point to a source that explains, how could that be, that this feature was supported before?

How many more changes like this are planned/possible in Scala before it matures enough? – noncom Dec 20 '11 at 14:21 @noncom: for what it's worth, I tend to agree. However if the only solution (as per the thread I've linked) involved the compiler magically adding a constructor to all classes implementing the trait, I would be wary of subtle corner cases when further inheritance happens (similar to what used to happen with case class inheritance).

– Paolo Falabella Dec 20 '11 at 14:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions