Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use \sigma instead of raw unicode character in math mode, as it
does not render in the PDF otherwise.
- Loading branch information
1352994
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may not be very strong at math stuff, so probably no surprise that I stumbled upon these lines for a couple of day already, still not able to properly understand. Let’s say that we have a type
T
, which happens to be parameterized by typesT_1
up toT_n
, andT
is a type constructor taking exactlyn
type parametersa_1
up toa_n
. Then, a lower boundL_i
would be the type, for which the actual used type parameter must be the same type or its supertype, and an upper boundU_i
would be the type, for which the actual used type parameter must be the same type or its subtype. Now let’s say that for everyi
from1
ton
, the following must be true for the parameterized type to be well-formed:L_i <: T_i <: U_i
. Also sincea_i
is kind of a variable, the same would apply forL_i <: a_i <: U_i
, after fillinga_i
with the used type, like a substitution. So, the question now: shouldn’t the σ be in the middle? Or is this about something different, my only guess being that the type constructor would not really be correct if the lower bound was a supertype of the upper bound? Thanks for help!1352994
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Some mailing list might be a better place for this).
All of that is correct :-)
No... but this paragraph is not talking about defining, say,
List[T]
, but about using it, sayList[Int]
. In this case,T_1 = Int
, because theT_i
are the actual arguments, not the formal parameters. So inT_i
the substitution was already done, if you want. However, you still need it for the bounds.To see bounds, we need to look at something bigger, say
TreeMap[I, String]
, assuming the definition:In
TreeMap[I, String]
, we haveT_1 = I
, andT_2 = String
, butU_1 = Comparable[A]
, which still containsA
! So we need the substitution σ to replace thatA
byT_1
, that isI
.Hope this helps!
1352994
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably, the spec text could maybe be clarified a bit. It's not bad, it's just more spec-y than tutorial-y.
1352994
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, now I get it! Thanks, it makes sense now.
And yes, it could be more clarified throughout more places than just this one, the math-y style is not always obvious.