I just found that, it seems, one of the oldest and frequently used logical operator in CW is not documented. Therefore, it’s impossible to argue whether it works correctly or not in some context. In my opinion, the compiler generates the wrong code if the reference us not just an address:
evaluated as TRUE. Yes, both Ref1 and Ref2 refer to the same memory but the size of referenced memory is different. As result, dereferenced values of Ref1 and Ref2 are not equal and effect of assignments
Ref1 = '0123456789'
Ref2 = '0123456789'
is very different.
The problem exists for reference variables of types the ADDRESS function is applicable for. So, it’s possible to compare addresses only for such reference variables. The reference equality operator could do more work.
Your opinion, how the reference equality operator has to work for references including not addresses only?
I think your ref1 example value are incorrect, but I know what you mean.
To me, I was always only comparing the reference address, and this issue never came up.
It could possibly break existing code if you were to change the way comparison works.
I wonder if another operator kind of like deep assign would be useful, or maybe just a StringRefComparison() function would be fine. Perhaps the function could have switches for address, size, and value equality as a parameter.
I agree with you that it is wrong but I am not sure whether it should be fixed. If it were fixed it could silently break someone’s code that has been happily working for years.
Of course if that were the case (relying on buggy behaviour) then you could argue it is about time they fixed their own code to use if address(ref1) = address(ref2).
Fortunately I don’t think this &= would be used very much by average Clarion users in their own code.