A.M. Hoornweg 144 Posted February 22, 2021 Hello all, I see that Delphi supports both bitwise and logical versions of and/or/xor operator overloading, but I'm not 100% sure about the difference between the two concepts. Assume I have a certain record type, and that I want to implement "AND", "OR" and "XOR" operators, each resulting in some kind of merge of the original input records. The syntax I would like to use in my code would simply be "A:=(B OR C);" Do I need to implement BitWiseOr etc or LogicalOr, and if I implement both, how does Delphi decide which of the two is going to be used? Share this post Link to post
David Heffernan 2345 Posted February 22, 2021 It's explained in the documentation. Which should always be the first port of call when contemplating such an issue. Its here: http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading_(Delphi) I could highlight the key text for you, but I'm sure you are more than capable of finding it. Share this post Link to post
Uwe Raabe 2057 Posted February 22, 2021 (edited) From the Docwiki: Quote For a logical operator and a bitwise operator using the same symbol, the logical operator is used only when the operands are booleans. Since the type of record for this record operator is not a boolean, a logical operator will only be used when the other operand is a boolean. Oops: too late Edited February 22, 2021 by Uwe Raabe Share this post Link to post
A.M. Hoornweg 144 Posted February 22, 2021 I did consult the wiki but somehow managed to skip this line of text ten times. It must be monday morning .... Thanks for pointing it out! Share this post Link to post