Errors, bugs, questions - page 1003

 
stringo:

ts==true and ts!=NULL are completely different expressions.

Moreover

ts==true and ts!=false are also different expressions

Do you know how they are different? Not only in syntax, but also in semantics.

But the point of the question was that ts is an array. And why does this if(ts) compile and the above doesn't.
 
sion:
Only the point of the question was that ts is an array. And why will this if(ts) compile and the above mentioned don't.

The expression if(ts) means that the array object ts actually exists. I specifically brought up semantics.

Do you want to prohibit compilation of this case or a warning will suffice? (By the way, there must be a warning. If there is no warning, it's our fault, something is broken off)

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

stringo, 2013.06.17 06:35

If(ts) expression means that the ts array object actually exists. I specifically mentioned semantics.

Do you want to prohibit the compilation of this case or is a warning enough? (By the way, there should be a warning. If there is no warning, it's our fault, something is broken)


int ts[20];

void OnInit()
{
ts[0]=0;ts[1]=1;
if(ts)Print("ts[0]=0");
ts[0]=1;
if(ts)Print("ts[0]=1");
}

void OnTick()
{

}

2013.06.17 08:41:31 test_forum (EURUSD.e,M15) ts[0]=1It
looks
more
like it is working with the first cell of the array.
 
#import "Test.ex5"
   void A();
#import "5Test.ex5"
   void A();
#import "Test5.ex5"
   void A();
#import

void B() { Test::A(); } //нормально
void C() { Test5::A(); } //нормально
void D() { 5 Test::A(); } //ошибка компиляции

ServiceDesk does not acknowledge the error, referring to the fact that identifiers cannot start with a number.

But 5Test is not an identifier, it is a filename. And file names can start with a digit and no restrictions have been imposed on #import .ex5 file names

 
A100:

ServiceDesk does not acknowledge the error, referring to the fact that identifiers cannot start with a number.

But 5Test is not an identifier, it is a filename. And filenames can begin with a digit and no restrictions were imposed on #import .ex5 file names

5Test::A is an identifier.

And 5Test is recognized as a file name as long as this name is enclosed in quotes in the import sentence (by the way, you have "5Test.ex5" written there as well).

 
This is why C/C++ compilers automatically add an underscore (_) to the internal representation of the function name in the file/module, so that the ending name "_5TestA" does not start with a number, which ensures compatibility
 
A100:
That's why C/C++ compilers automatically add an underscore character (_) to the internal representation of function name in a file/module, so that the resulting name "_5TestA" doesn't start with a number, which ensures compatibility

As it turned out, so it turned out. You just have to accept it.

This is a dangerous place to edit - the compiler's behaviour can change so much that no one will be happy.

 
stringo:

This is a dangerous place to edit - the compiler's behaviour can be changed so much that no one will be happy.

I agree.

Please take a look at this example:

#define  aX( X ) (X)
void K()
{
        int aX = 10;
        Print( aX( 5 ) );
        Print( aX ); 
}
// ошибка компиляции

The C/C++ compiler has enough brains to distinguish the aX variable from the aX( X ) parametric macro.

Parametric macros are the only alternative in the absence of inline functions and the names can often overlap in lengthy code

 
A100:

Agreed.

Please take a look at this example:

The C/C++ compiler in a similar situation has the wit to distinguish the variable aX from the parametric macro aX( X )
See a therapist! (into servicedesk)
 
Rosh:

Sure, just published examples the other day:

  1. Demo_IndicatorSetInteger
  2. Demo_IndicatorSetDouble
  3. Demo_IndicatorSetString

Thank you! I have understood it with your help.