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 !!!
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 !!!
Life is hard ;)
ReplyDeletevar
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;
I feel like a PHP developper just now :)
ReplyDeleteThis is one of my main gripes about lots of RTL/VCL/FMX code: conventions are often lacking.
ReplyDeletePrimož Gabrijelčič you can't mix reference and function ... and you can't decalre a reference type without a type ...
ReplyDeletetype
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;
Indeed, I didn't test it. One has to do it your way.
ReplyDeleteWe could introduce new methods that follow one convention. Enter a QP.
ReplyDeleteDavid Millington https://quality.embarcadero.com/browse/RSP-16549
ReplyDeleteDavid Millington "Works As Expected"
ReplyDeletePaul 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.
ReplyDeleteMy frustration with issues like these isn't the resolution, but that it takes almost a year to get a response at all.
ReplyDeletea QP has never changed as fast as this one...G+ effect ?
ReplyDeletecomp is a type.. This hurts my eyes....
ReplyDeleteDavid 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