- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
Table 15.25-B在 JLS 版本 8 中说条件表达式的类型
true ? null : 0.0
是 lub(null,Double)
,其中 lub
似乎是来自 section 4.10.4 的一些疯狂不可理解的东西.
这似乎与 Double
类型不同,或者他们可能只是写成 Double
,就像他们在表的其他地方所做的那样。不过,尚不清楚可能存在什么差异。我试图从第 4.10.4 节开始解决这个问题,但是当我到达关于
Let lub(U1 ... Uk) be:
Best(W1) & ... & Best(Wr)
他们好像在说这种类型是 null 和 Double 类型的交集类型,这毫无意义。
什么是lub(null, Double)
?具有此类型的条件表达式的行为与其类型仅定义为 Double
有何不同?
最佳答案
就是Double
.
非正式地,lub(null, Double)
是(一个合适的近似值)包含 null
的所有值的最具体的类型类型和 Double
类型,最具体的类型是 Double
.
形式上,我们可以通过 lub
的定义来工作在 JLS section 4.10.4 ,我们发现 lub(null, Double)
是Double
:
The least upper bound, or "lub", of a set of reference types is a shared supertype that is more specific than any other shared supertype (that is, no other shared supertype is a subtype of the least upper bound). This type, lub(U1, ..., Uk), is determined as follows.
If k = 1, then the lub is the type itself: lub(U) = U.
Otherwise:
For each Ui (1 ≤ i ≤ k):
Let ST(Ui) be the set of supertypes of Ui.
ST(null) is the set of all reference types , ST(Double) 是 {Object, Number, Double}。
Let EST(Ui), the set of erased supertypes of Ui, be:
EST(Ui) = { |W| | W in ST(Ui) } where |W| is the erasure of W.
EST(null)是所有引用类型的删除集合,EST(Double)是{Object, Number, Double}。
Let EC, the erased candidate set for U1 ... Uk, be the intersection of all the sets EST(Ui) (1 ≤ i ≤ k).
EC 是 EST(null) 和 EST(Double) 的交集,所以 EC 是 {Object, Number, Double}。
Let MEC, the minimal erased candidate set for U1 ... Uk, be:
MEC = { V | V in EC, and for all W ≠ V in EC, it is not the case that W <: V }
MEC 是 EC 中没有适当子类型的所有类型的集合。 Double 是 Number 和 Object 的真子类型,所以 MEC = {Double}。 ( W <: V
表示类型 W
是类型 V
的子类型。类型被认为是其自身的子类型,因此他们指定 W ≠ V 以仅计算适当的子类型。)
For any element G of MEC that is a generic type:
[lots of text]
MEC 不包含泛型类型,因此我们可以跳过这一点。
Let lub(U1 ... Uk) be:
Best(W1) & ... & Best(Wr)
where Wi (1 ≤ i ≤ r) are the elements of MEC, the minimal erased candidate set of U1 ... Uk;
and where, if any of these elements are generic, we use the candidate parameterization (so as to recover type arguments):
Best(X) = Candidate(X) if X is generic; X otherwise.
Candidate
在我们跳过的部分中定义;我们仍然可以跳过它,因为它只对泛型类型有影响。
lub(null, Double) 是 Best(Double),Best(Double) 是 Double,所以 lub(null, Double) 是 Double。
关于java - 什么是 lub(null, Double)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43506017/
下面的代码有效,我觉得double(double)和double(*)(double)没有区别,square和 &square,我说得对吗? #include double square(doubl
我知道我的作业很草率,这是我在这门课上的第 4 次作业。任何帮助将不胜感激,谢谢。 double getPrincipal(0); double getRate(0); double getYe
我遇到了那个错误,当我使用类时,我在使用函数指针时遇到了这个错误。我的函数'ope'函数我该如何解决 evaluator::function(){ double (*ope) (dou
问题://故事从哪里开始 Graphics 类型中的方法 drawLine(int, int, int, int) 不适用于参数 (double, double, double, double) g.
我有一张 map> m1 形式的 map .我可以将其复制到 map m2 形式的 map 吗?这样键是相同的,并且 m2 中的值是 get(m1->second) 不使用循环?谢谢! 最佳答案 这样
有没有办法获取vector> 的“.first”和“.second”的连续内存? ?我的意思是: void func(int N, double* x, double* y) { for (i
我正在尝试将自定义 lambda 传递给需要函数指针的函数(更准确地说是 zero 中的 Brent library 函数)。 我的想法是,我将使用参数创建一次 lambda,然后用多个值对其求值 x
这是一个很简单的问题,让我很困惑。 我收到一个源文件的以下错误,但另一个没有: 4 src/Source2.cpp:1466: error: no matching function for cal
struct CalculatorBrain { private var accumulator: Double? func changeSign(operand: Double) -
在我正在进行的项目中,我尝试使用 curlpp库来发出一个简单的 html GET 请求。当我将 cpp 文件传递给 g++ 时,出现以下错误: /usr/local/include/curlpp
不使用double就能获得quadruple精度超过16位的数字吗?如果可能的话,这取决于编译器还是其他?因为我知道有人说他使用double精度,并且具有22位精度。 最佳答案 数据类型double
我正在寻找有关特斯拉 GPU 中硬件如何实现 double 的信息。我读到,两个流处理器正在处理单个 double 值,但我没有找到 nvidia 的任何官方论文。 提前致谢。聚苯硫醚为什么大多数 G
这个问题在这里已经有了答案: Passing capturing lambda as function pointer (10 个答案) 关闭 2 年前。 我有这个错误 error: cannot
情况:我有一个元组列表,其中添加了一个元组: List> list = new List>(); list .Add(new Tuple(2.2, 6.6)); 一切似乎都还好。但是......在 D
我有一个 JList,里面有一堆名字,还有一个包含这些名字值的数组 final Double[] filmcost = { 5.00, 5.50, 7.00, 6.00, 5.00 }; 我想做的是,
我试图找出牛顿法来求方程的根。这个错误出来了,我无法处理。 double fn(double n){ return sin(n)+log(n)-1; } double f1n(double n
我有一个 junit 测试断言两个 Double 对象,具有以下内容: Assert.assertEquals(Double expected, Double result); 这很好,然后我决定将其
我正在尝试引入部分数据文件来填充数组,用户尝试了三次输入正确的数据文件名。我一再遇到这些错误。我知道像 arr 这样的数组只是一个指向内存块的指针。 #include #include #incl
我正在尝试完成复习题(为即将到来的编程决赛),但是,我无法解决这个问题,因为我不断收到错误(标题)。正如预期的那样,我将发布问题和我尝试的解决方案。 问题: 给定以下函数定义:void swap(do
任何人都知道如何实现这一目标。我已经尝试了通常的公式,但我只得到正数 Double.NEGATIVE_INFINITY) return d; } } 这将以相同的概率
我是一名优秀的程序员,十分优秀!