清单2:Frontier:RPC中强制类型转换。
强制类型转换关闭或挂起了正常的类型检查(第2.3节)。
By using a cast, the programmer turns off or dampens normal type-checking (Section 2.3, p. 44).
它只需调用底层Hibernate方法和添加强制类型转换。
It's just a matter of calling the underlying Hibernate methods and adding the casts.
它进行静态类型检查,并且不允许强制类型转换,因而对于类型而言是安全的。
It is statically type-checked and does not allow type coercion, so is safe with regards to types.
毕竟,强制类型转换对于编译器来说就是一个提示,表明您清楚自己正在做些什么。
After all, casts are a hint to the compiler that you think you know what you're doing.
这类规则被分成17个子类,这些子类关注于强制类型转换,可移植性以及反射等等。
The rules in this category are subdivided into 17 additional subcategories that allow you to confine your inspection to areas such as casting, portability, reflection, and so on.
不过,如果您的确想要得到值的列表,可以对所返回的dict对象进行强制类型转换。
But, if you really want a list of values, you can always cast the returned dict object. For example.
使用动态强制类型转换要小心。只要有可能,定义和使用虚函数比直接接管类型管理好得多。
Dynamic casts should be used with caution. Whenever possible, it is much better to define and use a virtual function rather than to take over managing the types directly.
显式使用强制类型转换的另一个原因是:可能存在多种转换时,需要选择一种特定的类型转换。
Another reason for an explicit cast is to select a specific conversion when more than one conversion is possible.
Python中既有强制类型转换也有强迫同型,通常使用更多的是前者(“显式优于隐式”)。
Python contains a mixture of casts and coercions, with a usual preference for the former (" explicit is better than implicit ").
擦除的另一个后果是,对泛型类型参数是用强制类型转换或者instance of毫无意义。
Another consequence of erasure is that using casts or instanceof with generic type parameters doesn't make any sense. The following code will not improve the type safety of your code at all.
看过了TimeSeries函数和强制类型转换以及其他元素之后,虚表看上去是一种自然的选择。
After seeing the TimeSeries functions and casts and other elements, a virtual table looks like an easy choice.
因此在决定如何对该方法的返回值进行强制类型转换时,必须同时考虑预期的返回类型和所用的数据模型。
One must therefore take into account both the expected return type and the data model when deciding how to cast the object that this method returns.
当具有基类的引用或指针,但需要执行不是基类组成部分的派生类操作的时候,需要动态的强制类型转换。
Dynamic casts are needed when we have a reference or pointer to a base class but need to perform operations from the derived class that are not part of the base class.
这种情况下需要强制类型转换函数(如 $elem castas xs:integer)来保持查询的有效性。
In this case, casting functions (like $elem cast as xs:integer) are needed to keep the queries working.
换句话说,编译器生成的代码与您手工编写的不用泛型、检查程序的类型安全后进行强制类型转换所得到的代码基本相同。
In other words, the compiler generates pretty much the same code you would have written by hand without generics, casts and all, after checking the type-safety of your program.
比范围更加微妙的是指针和整型之间的转换;由于这些转换通常都包括强制类型转换,因此编译器很难告诉您到底做错了什么。
More subtle than ranges are conversions between pointers and integers; because these conversions generally involve casts, it's hard for the compiler to tell you what you're doing wrong.
CriteriaQuery被传递给一个可执行查询并保留类型信息,这样可以直接访问选择列表的元素,而不需要任何运行时强制类型转换。
CriteriaQuery is transferred to an executable query with its type information preserved so that the elements of the selected list can be accessed without any run-time casting.
通过在VerboseEditor中实现适当的方法,可以容易地增加对报告强制类型转换、instance of检查和catch块的支持。
I could easily add support for reporting casts, instanceof tests, and catch blocks by implementing the appropriate methods in VerboseEditor.
另一个例子,在调用宿主对象的函数时,如何进行类型强制转换,这也是没有规定的。
Another example is that it's not explained how types are coerced when calling functions on host objects. For example, when you do.
其次,它消除了易出错的类型强制转换的需要(这是一个在查询操作中比在CRUD中更常见的问题)。
Secondly, it removes the need for error-prone type casts. (a problem more common with query operations than CRUDs.)
CAST函数被调用两次,以将输入参数的值(针对城市和州)强制转换适当的数据类型。
The cast function is called twice to cast the values of the input parameters (for city and state) to appropriate data types.
最后,可以根据列编号为这些列建立索引,并直接强制转换结果(对于某些类型)。
Finally, you can index into the columns by column number and cast the results directly (for some types).
这种方法可除去上面代码中类型强制转换的需要,但不修正错误。
This approach would eliminate the need to cast in the above code, but it would not fix the bug.
这样做经常需要添加类型强制转换来编译代码。
Doing so often necessitates the addition of casts to get the code to compile.
简言之,这些方法的本质总是使您确信代码块内部的不变量会确保代码块中的任何类型强制转换都将成功。
In short, the moral to this story is to always convince yourself that the invariants inside a code block ensure that any casts in the block will always succeed.
注意,在清单2中,从集合中提取项并不需要将其强制转换为正确的类型。
Notice in Listing 2 that fetching an item out of a collection doesn't require a cast to the right type.
治疗和预防措施:把类型强制转换代码分解到每个类的单独方法中去。
Cures and preventions: Factor the casting code out into separate methods for each class.
比如泛型更改——泛型类型信息——由编译器用于实施编译时安全,但是生成的字节码仍然到处使用强制转换。
Likewise with the generics changes — the generic type information is used by the compiler to enforce compile-time safe usage, but the generated bytecode still USES casts everywhere.
比如泛型更改——泛型类型信息——由编译器用于实施编译时安全,但是生成的字节码仍然到处使用强制转换。
Likewise with the generics changes — the generic type information is used by the compiler to enforce compile-time safe usage, but the generated bytecode still USES casts everywhere.
应用推荐