Operator overloading: implies, +=, *=...

Issue #255 closed
Toky Olivier Razanakotonarivo created an issue

Hello,

Can you tell please how to implement operator overloading with += or *= operators? And can you tell what is “Implies” operator? There is no documentation about it if I’m not wrong.

Thank you so much.

Comments (4)

  1. Eric Grange repo owner

    Hi,

    ”implies” was added in compatibility with RemObjects Oxygen, it checks for a mathematical implication, ie. “a implies b” is equivalent to “(not a) or b” ( https://www.delphitools.info/2011/01/19/leaps-and-bounds-of-dwscript/)

    At the moment the combined assignement operators are not overloadable, back in the day when I looked at it there was an ambiguity on how they should handle properties, so they were left aside, and the issue got a bit buried since :/

    The main ambiguity IIRC was whether

    obj.prop += val;
    

    should be treated as a custom implementation for the syntax sugar that '+=' is

    obj.prop := obj.prop + val;
    

    or as a method

    obj.prop.plus_assign(val)
    

    The syntax sugar is the most logical/least surprise one, but has issues when property getter/setter are involved (it really needs to be implemented a template in those cases to be truly beneficial, like its is in various C++ vector libraries).

    The method approach is the one that made sense for things like using “+=” as an alternative to Add(), but makes very limited sense outside of those uses, so it was debatable if it did anything else than bring confusion.

    I have not looked into the subject since, not sure if Embarcadero/FreePascal crowds made any decision there that could be followed.

  2. Toky Olivier Razanakotonarivo reporter

    Hi,

    Thank you for you response. I just asked if it there is a method to overload it or I did it wrongly but it if it’s the case, I will change my approach. So at this time, I can use them but cannot overload. Thank you.

  3. Log in to comment