如何从具有相同名称 IsTesting() 的 class 方法调用内置函数 IsTesting()?
How to call a built-in function IsTesting() from a class-method which has the same name IsTesting()?
我有以下代码:
class Check {
public:
static bool IsTesting() {
#ifdef __MQL4__
return IsTesting(); // _______ @fixme: Here the infinite recursion occurs
#else
return (MQL5InfoInteger(MQL5_TESTER));
#endif
}
};
void OnStart() {
Print("Starting...");
if (Check::IsTesting()) { // _______ a first call to a class-method
Print("This is a test.");
}
}
我在其中创建了我想调用的 class 方法,但是代码进入了无限递归,因为 class-方法的名称与构建的系统相同-in(全局)函数(IsTesting()
),而不是调用前者,它递归地调用后者( it-self )。
如何阐明我想调用全局函数而不是局部 class 方法,而不更改方法名称?
前缀 IsTesting()
with ::
,告诉编译器使用全局作用域。例如:
static bool IsTesting() {
#ifdef __MQL4__
return ::IsTesting(); // @fixme: Here is the loop occuring.
#else
return (MQL5InfoInteger(MQL5_TESTER));
#endif
}
虽然 ::
-命名空间解析技巧已经勾勒出一个方法,
整个问题是
主要充分设计/重构代码
当前可用&有效的语言语法规则.
There is a "fully" identical set see remark below
of functions in the New-MQL4.56789
language,
所以
在编译时指令的支持下,可以保持代码库的清洁和使用(甚至可以对相应的情况使用词法 #define
替换),但要保持示例的结构:
class Check {
public:
static bool IsTesting() {
#ifdef __MQL5__
return( MQL5InfoInteger( MQL5_TESTER ) );
#else
return( MQLInfoInteger( MQL_TESTER ) );//_____ one could hardly find
// a better example of MetaQuotes Inc.
// practices on artificially
// injecting features not adopted MQL5
// into a stable MQL4 market
#endif
}
};
备注
有关稳定语言的详细信息(MQL4
已经存在了大约十年)
突然
失去了所有代码库支持
并且
在很长一段时间内经历了很多语法错误
一旦未能接受 一个新的、尚未成熟的产品(由于经纪人方面的许可问题和 MQL5
一个明亮的新语言概念,实际上没有人在等待)
再加上只是市场的胃口和猜猜发生了什么,
一个大满贯炸弹大小的陨石坑出现在全球范围内,这为重大re/factoring 整个代码库,包括。 DLL 接口重新设计——可以查看我的其他帖子 related to this rather devastating & painfull experience on this subject
这不是轻率的咆哮,而是血腥的代价,MQL4
DevTeams 不得不为再次获得相同的代码付出代价 运行,因为它是 运行已经好几年了。
Out of doubts -- a bloody lesson to remember.
我有以下代码:
class Check {
public:
static bool IsTesting() {
#ifdef __MQL4__
return IsTesting(); // _______ @fixme: Here the infinite recursion occurs
#else
return (MQL5InfoInteger(MQL5_TESTER));
#endif
}
};
void OnStart() {
Print("Starting...");
if (Check::IsTesting()) { // _______ a first call to a class-method
Print("This is a test.");
}
}
我在其中创建了我想调用的 class 方法,但是代码进入了无限递归,因为 class-方法的名称与构建的系统相同-in(全局)函数(IsTesting()
),而不是调用前者,它递归地调用后者( it-self )。
如何阐明我想调用全局函数而不是局部 class 方法,而不更改方法名称?
前缀 IsTesting()
with ::
,告诉编译器使用全局作用域。例如:
static bool IsTesting() {
#ifdef __MQL4__
return ::IsTesting(); // @fixme: Here is the loop occuring.
#else
return (MQL5InfoInteger(MQL5_TESTER));
#endif
}
虽然 ::
-命名空间解析技巧已经勾勒出一个方法,
整个问题是
主要充分设计/重构代码
当前可用&有效的语言语法规则.
There is a "fully" identical set see remark below
of functions in the New-MQL4.56789
language,
所以
在编译时指令的支持下,可以保持代码库的清洁和使用(甚至可以对相应的情况使用词法 #define
替换),但要保持示例的结构:
class Check {
public:
static bool IsTesting() {
#ifdef __MQL5__
return( MQL5InfoInteger( MQL5_TESTER ) );
#else
return( MQLInfoInteger( MQL_TESTER ) );//_____ one could hardly find
// a better example of MetaQuotes Inc.
// practices on artificially
// injecting features not adopted MQL5
// into a stable MQL4 market
#endif
}
};
备注
有关稳定语言的详细信息(MQL4
已经存在了大约十年)
突然
失去了所有代码库支持
并且
在很长一段时间内经历了很多语法错误
一旦未能接受 一个新的、尚未成熟的产品(由于经纪人方面的许可问题和 MQL5
一个明亮的新语言概念,实际上没有人在等待)
再加上只是市场的胃口和猜猜发生了什么,
一个大满贯炸弹大小的陨石坑出现在全球范围内,这为重大re/factoring 整个代码库,包括。 DLL 接口重新设计——可以查看我的其他帖子 related to this rather devastating & painfull experience on this subject
这不是轻率的咆哮,而是血腥的代价,MQL4
DevTeams 不得不为再次获得相同的代码付出代价 运行,因为它是 运行已经好几年了。
Out of doubts -- a bloody lesson to remember.