Damned !

Damned !

var
Comp : function(const s1, s2: string): Boolean;
begin
if CheckBox1.Checked then
Comp := ContainsText
else
Comp := AnsiStartsText;

why are the parameters in a reverse order !!!

Comments

  1. Life is hard ;)

    var
    Comp : function(const s1, s2: string): Boolean;
    begin
    if CheckBox1.Checked then
    Comp := ContainsText
    else
    Comp := function(const s1, s2: string): Boolean begin Result := AnsiStartsText(s2,s1); end;

    ReplyDelete
  2. I feel like a PHP developper just now :)

    ReplyDelete
  3. This is one of my main gripes about lots of RTL/VCL/FMX code: conventions are often lacking.

    ReplyDelete
  4. Primož Gabrijelčič you can't mix reference and function ... and you can't decalre a reference type without a type ...

    type
    TComp = reference to function(const s1, s2: string):Boolean;
    var
    Comp : TComp;
    begin
    if CheckBox1.Checked then
    Comp := function(const s1, s2: string): Boolean begin Result := ContainsText(s1,s2); end
    else
    Comp := function(const s1, s2: string): Boolean begin Result := AnsiStartsText(s2,s1); end;

    ReplyDelete
  5. Indeed, I didn't test it. One has to do it your way.

    ReplyDelete
  6. We could introduce new methods that follow one convention. Enter a QP.

    ReplyDelete
  7. David Millington "Works As Expected"

    ReplyDelete
  8. Paul TOTH I see it was "expected" because you can't change the order of params of existing methods (which is fair) - but it ignored adding a new one. Please click "Dispute resolution" and maybe add a comment why. I've reopened it internally already.

    ReplyDelete
  9. My frustration with issues like these isn't the resolution, but that it takes almost a year to get a response at all.

    ReplyDelete
  10. a QP has never changed as fast as this one...G+ effect ?

    ReplyDelete
  11. comp is a type.. This hurts my eyes....

    ReplyDelete
  12. David Millington Of course it is not really rocket science to write a simple wrapper that reverses the parameters, either. That is what I would do, instead of relying on others to fix this.

    ReplyDelete

Post a Comment