[英]Notation S[F1:=T1,…,Fn:=Tn] in JSL
In section 4.5 of JLS (Parameterized Types) is mentioned the following notation: S[F1:=T1,...,Fn:=Tn]
. 在JLS(参数化类型)的4.5节中提到了以下符号: S[F1:=T1,...,Fn:=Tn]
。
I do not exactly unbderstand the meaning of this notation. 我并不完全不理解这种符号的含义。
It is mentioned in the following paragraph: 在以下段落中提到:
A generic type has type parameters F1,...,Fn with corresponding bounds B1,...,Bn. 泛型类型具有类型参数F1,...,Fn,其具有对应的边界B1,...,Bn。 Each type argument Ti of a parameterized type ranges over all types that are subtypes of all types listed in the corresponding bound. 参数化类型的每个类型参数Ti都在所有类型的范围内,这些类型是相应边界中列出的所有类型的子类型。 That is, for each bound type S in Bi, Ti is a subtype of S[F1:=T1,...,Fn:=Tn] (§4.10). 也就是说,对于Bi中的每个束缚类型S,Ti是S [F1:= T1,...,Fn:= Tn](§4.10)的子类型。
The meaning of the statement above is clear. 上述陈述的含义很清楚。
But it is not clear for me why we have [F1:=T1,...,Fn:=Tn]
after S
但是我不清楚为什么在S
之后我们有[F1:=T1,...,Fn:=Tn]
Here ia my thinking. 这是我的想法。
The notation [F1:=T1,...,Fn:=Tn]
is a substitution of each type parameter Fi
with concete type (or wildcard) Ti, i=1,2,...n
. 符号[F1:=T1,...,Fn:=Tn]
是用类型(或通配符) Ti, i=1,2,...n
替换每个类型参数Fi
。
Generic class can be thought as a function with (n+1)
arguments f(F1,F2,...,Fn, S)
, where Fi
- is a type parameter and S
belong to the following finite set {B1,B2,...,Bn}
. 通用类可以被认为是具有(n+1)
参数f(F1,F2,...,Fn, S)
函数,其中Fi
- 是类型参数, S
属于以下有限集{B1,B2,...,Bn}
。 If we substitute [F1:=T1,...,Fn:=Tn]
we get function with one argument: g(s)=f(T1,T2,...,Tn,S)
. 如果我们用[F1:=T1,...,Fn:=Tn]
代替[F1:=T1,...,Fn:=Tn]
我们得到一个参数的函数: g(s)=f(T1,T2,...,Tn,S)
。
Considering that [F1:=T1,...,Fn:=Tn]
is a substitution of Fi
with Ti, i=1,2,...,n
we can introduce new notation: f(T1,T2,...,Tn,S)=h(S)[F1=T1,...,Fn=Tn]
. 考虑到[F1:=T1,...,Fn:=Tn]
是用Ti, i=1,2,...,n
代替Fi
Ti, i=1,2,...,n
我们可以引入新的符号: f(T1,T2,...,Tn,S)=h(S)[F1=T1,...,Fn=Tn]
。
Function h(S)
should be linear: h(S)=S
函数h(S)
应该是线性的: h(S)=S
Finally we have: f(T1,T2,...,Tn,S)=S[F1=T1,...,Fn=Tn]
. 最后我们得到: f(T1,T2,...,Tn,S)=S[F1=T1,...,Fn=Tn]
。
Hence notion S[F1=T1,...,Fn=Tn]
means: get one of upper bound Bi
in fixed values Fi=Ti
. 因此,概念S[F1=T1,...,Fn=Tn]
意味着:以固定值Fi=Ti
得到上界Bi
中的一个。
It just looks wrong to me. 这对我来说只是看错了。
First: without the bracketed part, the sentence is a correct restating of the previous statement, and both match my understanding of the java language. 第一:没有括号部分,句子是对前一个语句的正确重述,并且都符合我对java语言的理解。
Second: the notation is wrong. 第二:符号是错误的。 §4.10 references the subtyping and supertyping notation <: and :>, but what is actually used is the replacement notation := (not actually defined as replacement notation in version 8 but was in version 7, and used as replacement in other sections of the document). §4.10引用了子类型和超类型符号<:和:>,但实际使用的是替换符号:=(实际上没有在版本8中定义为替换符号,但在版本7中,并在其他部分用作替换符号)文献)。
Finally: The previous version of the JSL had an even more nonsensical version of the same notation. 最后:JSL的早期版本具有更为荒谬的相同表示法版本。
4.5. 4.5。 Parameterized Types 参数化类型
A generic class or interface declaration C (§8.1.2, §9.1.2) with one or more type parameters A1,...,An which have corresponding bounds B1,...,Bn defines a set of parameterized types, one for each possible invocation of the type parameter section. 具有一个或多个类型参数A1,...,An的泛型类或接口声明C(§8.1.2,§9.1.2)具有相应的边界B1,...,Bn定义了一组参数化类型,一个对于每个可能的类型参数部分的调用。
Each parameterized type in the set is of the form C where each type argument Ti ranges over all types that are subtypes of all types listed in the corresponding bound. 集合中的每个参数化类型都是C形式,其中每个类型参数Ti的范围超过所有类型,这些类型是相应边界中列出的所有类型的子类型。 That is, for each bound type Si in Bi, Ti is a subtype of Si[F1:=T1,...,Fn:=Tn]. 即,对于Bi中的每个束缚型Si,Ti是Si的子类型[F1:= T1,...,Fn:= Tn]。
It has the same brackets, but this time does not even mention what F is prior to being used in the brackets. 它具有相同的括号,但这次甚至没有提到在括号中使用之前的F。
It looks like the brackets were copied incorrectly when this section was rewritten between versions 6 and 7. Version 6 has the brackets but the simply mean the bounds check happens for each type parameter. 当在版本6和版本7之间重写此部分时,看起来括号被错误地复制。版本6具有括号,但简单的意思是对每个类型参数进行边界检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.