3

Should U_i not be rather T_i, as shown in the picture below ?

The same typo (IMHO) is also here.

enter image description here

If it is not a typo, then could someone please tell me where the meaning of T_i is specified ?

jhegedus
  • 20,244
  • 16
  • 99
  • 167

1 Answers1

3

It's not a typo, just a very poor choice of variables and confusion about the scope of their binding :)

In the first paragraph, from "A parametrized" to ", a_n.", the binding of the U_i variables refers to the type parameters, while T is bound to the actual parametric type. For example, say you had

val x : Map[Int, String]

Your T would be Map, your U_1 would be Int and U_2 would be String.

The second paragraph, on the other hand, is completely disconnected from the previous one. Here the type parameters are bound to variables T_1 ... T_n, the parametric type is NOT bound to anything and you have a binding of L_1 ... L_n to the lower bounds of the type parameters and a binding of U_1 ... U_n to the upper bounds of your parameter types.

In this case, had you got (this doesn't compile, it's just for example):

val x : Map[T1 <: AnyRef, T2 >: Int]

Then you'd have your T1, T2 as the actual type parameter, U1 = AnyRef , L2 = Int.

Hope it's clearer now :) (but yeah, poor choice of variables)

To see if you understood, try to guess what U2 and L1 are in the second example. Hint: Look at the type hierarchy of Scala ;)

Diego Martinoia
  • 4,592
  • 1
  • 17
  • 36
  • Thank you for the support! This is really a tough one ! What is the difference between U_i and a_i (within the first paragraph) ? So in your example, if in `val x : Map[Int, String]` U_1 is `Int` then what is a_1 ? – jhegedus Nov 07 '14 at 17:00
  • I think I understand your interpretation, I just don't understand what is the point in having both U_i and a_i in the first paragraph ? Is a_i the formal type parameter, while U_i is the actual type parameter ? If this is the case then I would argue that this choice of variable names is sooooooo confusing that U_i should be changed to T_i in the Scala Lang. Specs. – jhegedus Nov 07 '14 at 17:14
  • How can I call the attention of the Lang. Spec. writers to this inconsistent choice of notation ? – jhegedus Nov 07 '14 at 17:22
  • 1
    You are correct on U_i and a_1. I'm not sure about how to call for their attention, maybe here: http://docs.scala-lang.org/contribute.html ? You can contribute to the docs – Diego Martinoia Nov 08 '14 at 18:24
  • This was just fixed, see http://scala-lang.org/files/archive/spec/2.11/03-types.html#parameterized-types. Thanks @jhegedus for spotting and fixing this :) – gourlaysama Jan 31 '15 at 12:50