Delphi XE 中的集合的工作方式与 D7 中的工作方式不同
我在 Delphi 7 程序中有这个常量。它们不在 Delphi XE 下编译。
TYPE
TSingleChar= AnsiChar;
CONST
noData: TSingleChar= '.';
Ambiguity= ['x'];
DNA_Ambig= ['x', noData]+ Ambiguity;
[DCC 错误] E2026 常量表达式 预计。
- XE 中发生了什么变化导致我的旧代码无法编译?
- 我认为代码按原样被解释为 Unicode。我说得对吗?
I had this constants in a Delphi 7 program. They are not compiling under Delphi XE.
TYPE
TSingleChar= AnsiChar;
CONST
noData: TSingleChar= '.';
Ambiguity= ['x'];
DNA_Ambig= ['x', noData]+ Ambiguity;
[DCC Error] E2026 Constant expression
expected.
- What was changed in XE that my old code does not compile?
- I suppose that the code, as it is, is interpreted as Unicode. Am I correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样“修复”它:
就编译器而言,
Const_noData
是一个真正的 const,允许您使用以下命令初始化noData
和DNA_Ambig
它。而且您仍然遵循 DRY 原则,即noData
只有一个定义,即Const_noData
。"Fix" it like this:
The
Const_noData
is a true const as far as the compiler's concerned, allowing you to initialize bothnoData
andDNA_Ambig
using it. And you still respect the DRY principle, ie, there's only one definition fornoData
, theConst_noData
.不起作用。
确实有效。类型化常量根本不是真正的常量...
(请注意,这个问题与歧义无关。它是关于什么被认为是常量,什么不是。)
does not work.
does work. Typed constants aren't really constants at all...
(Notice that the issue has nothing to do with ambiguity. It is about what is considered a constant and what is not.)