Raheman Velji wrote 9 lines
You consider this "more readable"? Honestly, no... Code gets already convoluted enough if it uses macros, so something like that is definitely not needed. We are not C after all...
Also what you mentioned in your second article already works since quite some months in 2.7.1 and thus by extension in 3.0.0 and 3.1.1:
=== code begin ===
program tgeninherit;
{$mode objfpc}
type
generic TMyListBase<data_type> = class
procedure VirtualProc( data : data_type ); virtual; abstract;
procedure InternalProc; // <-- which uses VirtualProc
end;
generic TMyList<data_type> = class(specialize TMyListBase<data_type>)
end;
TIntegerList = class(specialize TMyList<Integer>)
procedure VirtualProc(data: Integer); override;
end;
TStringList = class(specialize TMyList<String>)
procedure VirtualProc(data: String); override;
end;
TBooleanList = class(specialize TMyList<Boolean>)
procedure VirtualProc(data: Boolean); override;
end;
procedure TMyListBase.InternalProc;
begin
VirtualProc(Default(data_type));
end;
procedure TIntegerList.VirtualProc(data: Integer);
begin
Writeln(data);
end;
procedure TStringList.VirtualProc(data: String);
begin
Writeln(data);
end;
procedure TBooleanList.VirtualProc(data: Boolean);
begin
Writeln(data);
end;
begin
end.
=== code end ===
Regards,
Sven