[fpc-pascal] Multiple active class helpers at same time

Ryan Joseph ryan at thealchemistguild.com
Tue Apr 24 10:12:22 CEST 2018



> On Apr 24, 2018, at 12:48 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> Because that is how helper currently work. Extending it with a new feature will not change that. 
> 

I made an example to see how this would look. What’s the problem with “last in wins” like seen below? Seems pretty straightforward to me. 

type
	TClassA = class
		procedure DoThis; virtual;
	end;

type
	TClassB = class (TClassA)
		procedure DoThis; override;
	end;

type
	TClassHelper_A1 = class helper for TClassA
		procedure DoThis; // overloads TClassA.DoThis
	end;

type
	TClassHelper_A2 = class helper for TClassA
		procedure DoThis; // overloads TClassHelper_A1.DoThis
	end;

type
	TClassHelper_B1 = class helper for TClassB
		procedure DoThis; // overloads TClassB.DoThis
	end;

var
	classA: TClassA;
	classB: TClassB;
begin
	classA.DoThis; // calls TClassHelper_A2.DoThis
	classB.DoThis; // calls TClassHelper_B1.DoThis



Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list