发明名称 Immutable types in imperitive language
摘要 An imperative framework having a more than one type is defined. At least one of the types is an immutable type, and the immutable type has at least one immutable field.
申请公布号 US9026993(B2) 申请公布日期 2015.05.05
申请号 US200812163868 申请日期 2008.06.27
申请人 Microsoft Technology Licensing, LLC 发明人 Duffy John;Hejlsberg Anders
分类号 G06F9/44 主分类号 G06F9/44
代理机构 代理人 Sullivan Kevin;Hoff Aaron;Minhas Micky
主权项 1. A computer memory storing computer executable instructions for controlling a computing device to perform a method comprising: defining an imperative framework having a plurality of types; defining at least one of the plurality of types within the imperative framework as an immutable type wherein all post-construction changes to objects of the immutable type is not possible, and wherein the immutable type includes at least one immutable field; and verifying the immutable type within the imperative framework with a plurality of rules including: variable assignments of fields of the immutable type are initonly and only occur as part of a declaration or in a static constructor of the same class;types used as fields in the immutable type are also immutable such that immutable types do not derive from mutable types wherein the immutability of a derived type is not affected with mutations of the base type, subjected to the conditions of, the immutable type does not override virtual members and does not access fields from a base type, andbase types can be immutability transparent;mutable types do not derive from immutable types; andimmutable types do not share a ‘this’ reference during construction verified by at least one of: stores and aliasing of the ‘this’ reference are declared illegal,analyzing code for aliasing of the ‘this’ reference,recursively tracing static method calls made from the constructor, anddynamic method calls are declared illegal.
地址 Redmond WA US