check pointer by "!" - page 2

 
Alain Verleyen #:

No ? Not so easy.

Maybe. It depends to what is applying the "same" ? 

Strictly speaking they are not the same as they are different.

Semantically they are not the same as we don't know how '!' is implemented with a pointer. Maybe !ptr is replaced by ptr== NULL || CheckPointer(ptr)==POINTER_INVALID by the compiler ? 

The final result is the same though. No ?

When going by the docs, the only logical interpretation seems to be:

 !ptr => (CheckPointer(ptr) == POINTER_INVALID)


 
Alain Verleyen #:
Semantically they are not the same as we don't know how '!' is implemented with a pointer. Maybe !ptr is replaced by ptr== NULL || CheckPointer(ptr)==POINTER_INVALID by the compiler ? 

Thank you, Alain. That's what I'm talking about and the reason for my question.

 
Dominik Egert #:
When going by the docs, the only logical interpretation seems to be:

 !ptr => (CheckPointer(ptr) == POINTER_INVALID)


Yeah but the documentation is not a trustworthy reference. They sometimes update it to fix bug in code instead of the reverse, so...
 
harryma23 #:
Unfortunately, I can't see the source code of the MQL compiler.

I don't know if the syntactical simplification if(!pointer) also checks for NULL. But apparently not.

Nevertheless, A little tip: 

Please don't answer such simple yes-or-no questions with contradictions or uncertainties – that is neither polite nor helpful. And if you don't "want" to answer such easy questions directly, then don't answer - that's not correct!


No. You are unclear about what it is you want answered.

I have answered from all sides now and will not provide more answers to you.
 
Alain Verleyen #:
Yeah but the documentation is not a trustworthy reference. They sometimes update it to fix bug in code instead of the reverse, so...
Yeah, but 

!NULL => true and 

ptr = NULL=> !ptr => false


 
Dominik Egert #:
Yeah, but 

!NULL => true and 

ptr = NULL=> !ptr => false


I am confused now 😂
 
Alain Verleyen #:
I am confused now 😂
:-)

How do I do a smiley???
Edit:

Let's see if he finally figures it out.
 
Dominik Egert #:
:-)

How do I do a smiley???
Edit:

Let's see if he finally figures it out.

On Windows you have them directly with WinKey+"."

On Linux I don't know.

 
harryma23 #:

Thank you, Alain. That's what I'm talking about and the reason for my question.

Played long enough, the point is, no matter what you do, both will evaluate to true, because in both cases you want to enter the if-statement.

!ptr if invalid will turn true.
!NULL will be true.
CheckPointer(ptr) == POINTER_INVALID will be true.

It doesn't matter. The only difference to ptr == NULL is, they are "function calls" or better said more than a comparison.

And no matter if ptr = NULL, it will still be a function call if you do: !ptr.

Get it now? If so, go back and check my answers, I gave and see if they now make sense.
 
Alain Verleyen #:

On Windows you have them directly with WinKey+"."

On Linux I don't know.

Oh, you fell for it. Sorry.