ata, 3);
end;
You will need to move the local const out of the procedure and declare it for what it is: a global variable. After making this change, the code segment above becomes:
var
somedata: Integer = 12;
procedure MyProc;
begin
Inc(somedata, 3);
end;
Code that relies heavily on the typed const quirk (such as the ActiveX control wrapper generator) can insert a {$WRITEABLECONST ON} directive in the source file as a quick fix. This practice is forbidden in the RTL, VCL, CLX, and DB source code and discouraged in the IDE sources, but acceptable for fringe units such as ActiveX control wrappers.
In general, you should note that the phrase "writeable constant" is an oxymoron. Prior versions of Delphi allowed them by default to maintain compatibility with an older 16-bit compiler, which is no longer important for most Delphi developers. Use good programming practice; avoid writeable constants.
三. Cardinal类型的负数值
过去,Delphi处理Cardinal类型的负数值时使用32位的机制,这样使得结果为一些零头的值(Cardinal类型允许的最大的值与当前值的差加一)。以下为例子:
var
c: Cardinal;
i: Int64;
begin
c := 4294967294;
i := -c;
WriteLn(i);
end;
在以往版本的Delphi中,I的值应当是2。但是这种情况下这个值明显不对。Delphi 6中,Cardinal类型是先转化为64位的有符号类型,然后取其负数值,所以最终结果I的值为-4294967294。
可能有已经存在的代码依赖于原先错误的Cardinal负数值的实现方法。读者应当对Delphi 的这一新特性引起足够的重视。花足够多的时间来检验你的代码中是否使用了对Cardianl的值的取负数是很值得的,同时确信一点,Delphi的这个新的特性对你的程序的正确性不构成影响。
Unary negation of Cardinal type
In the past, Delphi handled unary negation of Cardinal type numbers using 32 bit operations, which could lead to some odd results. Here is an example of code which uses unary negation:
var
c: Cardinal;
i: Int64;
begin
c := 4294967294;
i := -c;
WriteLn(i);
end;
In previous versions of Delphi, the value of i displayed would be 2. This is obviously incorrect behavior for this case. In Delphi 6, the unary negation is handled after promoting the Cardinal type to a 64 bit signed type, so the final value of i displayed is -4294967294.
It is possible that existing code may rely on the incorrect behavior of unary negation. Delphi users should be aware of this new behavior. It may be worth your time to check your code for instances of unary negation of Cardinal variables, and make sure that your application responds to the new behavior appropriately.
四. 单元DsgnIntf改名及相关变化
工程中对于DsgnIntf的引用,需要更新到一个新的名字:DesignIntf。可能还得加上DesignEditors,VCLEditors 和RTLConsts 到你的引用列表中。并且你还得将designide加入到你的Package的Requires的列表中。对dsnide50的引用可能得改为DesignIde,如果Delphi没有自动更改的话。
任何引用了IDesigner的运行期Package,需要用IdesignerHook来防止运行期时需要designide。运动期代码中,IDesignerHook 足以应付。设计时间的代码也可以使用IDesigner,但是代码要象下例一样:
var
RealDesigner: IDesigner;
...
SomeDesignerHook.QueryInterface(IDesigner,RealDesigner);
...
从IDesignerHook 的一个实例上获得真正的IDesigner接口。IDesignerHook的使用只需要引用Classes和Forms两个单元。IDesigner还需要用DesignIntf,该单元被包含在许多其它Packatge中,而其中的一些可能导致不可再次分发。
Borland在此希望感谢Field的测试员Matt Palcic,感谢他让我们对此引起注意。
DsgnIntf renamed and related changes
References to DsgnIntf in your project should be changed to the new Delphi 6 name, DesignIntf. You may also need to add DesignEditors, VCLEditors and RTLConsts to your uses clause. You will also need to add designide to your package''''s requires list. References to dsnide50 should probably also be changed to designide if that isn''''t changed automatically by Delphi.
Any runtime packages that use IDesigner need to use IDesignerHook to avoid a requirement of designide at runtime. In runtime code, IDesignerHook should suffice. Design-time code can use IDesigner, but should use something like
var
RealDesigner: IDesigner;
...
SomeDesignerHook.QueryInterface(IDesigner,RealDesigner);
...
To get the real IDesigner interface from an instance of IDesignerHook. IDesignerHook only requires Classes and Forms to be available. IDesigner requires DesignIntf, which includes many other packages, some of which may not be redistributable.
Borland wishes to thank field tester Matt Palcic for bringing these changes to our attention.
五. 组件编辑器的变化
Delphi 6中,类TComponentEditor有了不同的祖先。在Delphi 5中,它从TInterfacedObject
继承而来;现在它从一个新的类,TbaseComponentEditor继承而来。同时,TComponentEditorClass也变为TbaseComponentEditor的类类型,而不是TComponentEditor的类类型。这些体系结构上的变化可能需要你修改你的老的Delphi的工程。
Component editor changes
The class TComponentEditor has a different ancestry in Delphi 6. In Delphi 5, it descended from TInterfacedObject; it now descends from a new class, TBaseComponentEditor. Also, the class TComponentEditorClass is now a class of TBaseComponentEditor instead of TComponentEditor. These changes in hierarchy may require you to modify your older Delphi projects.
Borland wishes to thank field tester Clive Walden for bringing these changes to our attention.
上一页 [1] [2] [系统软件]BCB6 下devexpress 安装手记 [常用软件]Internet Explorer 6 Public Preview 最新出击!! [常用软件]painter 6 手绘实例《油彩篇》 [常用软件]painter 6 手绘实例《粉彩篇》 [常用软件]Painter 6 手绘实例《胶彩篇》 [VB.NET程序]VB.NET实现DirectSound9 (6) 声音特效 [VB.NET程序]Visual Basic 6 逆向工程与反逆向工程 (2) [VB.NET程序]Visual Basic 6 逆向工程与反逆向工程 (1) [VB.NET程序]Vb 6 中的多态 [VB.NET程序]几个 WMI 的例子(初级) - 1
|