On 20.02.2015 22:19, Raheman Velji wrote:
I have an idea called Interjections.  I have posted on the forum so that
everybody can access it nicely.  Here are the links:

http://forum.lazarus.freepascal.org/index.php/topic,27452.0.html
and its continuation
http://forum.lazarus.freepascal.org/index.php/topic,27453.0.html

Please include interjections in future versions of Free Pascal!
And ask me questions and comments if you have any!

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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to