|
|
|
|
|
by stefanos82
1146 days ago
|
|
> No metaprogramming in the language meant we had some parts of the code that were written in pascal to generate pascal code before compilation of the main project. Weird...if you are talking about Generics, FreePascal has them and work just fine, plus it compiles instantly! Here's a demo: program UseGenerics;
{$mode objfpc}{$H+}
type
generic TFakeClass<_GT> = class
class function gmax(a,b: _GT): _GT;
end;
TFakeClassInt = specialize TFakeClass<integer>;
TFakeClassDouble = specialize TFakeClass<double>;
class function TFakeClass.gmax(a,b: _GT): _GT;
begin
if a > b then
result := a
else
result := b;
end;
begin
{ show max of two integers }
writeln('Integer GMax: ', TFakeClassInt.gmax(23, 56));
{ show max of two doubles }
writeln('Double GMax: ', TFakeClassDouble.gmax(23.89, 56.5));
end.
|
|
> Weird…if you are talking about Generics
But aren’t they very clearly talking about metaprogramming, which is a completely different thing than generics?