[Pas2js] Testing generics
warleyalex
warleyalex at yahoo.com.br
Tue Oct 22 04:22:33 CEST 2019
generic function Min<T>(const A, B: T): T;
begin
if A < B then
Result := A else
Result := B;
end;
begin
// it compiles/worked as expected
specialize Min<Integer>(1, 0); // Min (1, 0): 0
specialize Min<Single>(3.14, 5); //Min (3.14, 5): 3.14
specialize Min<string>('a', 'b'); //Min ("a", "b"): a
(* but we can not compile the following: *)
WriteLn('Min (1, 0): ', specialize Min<Integer>(1, 0));
WriteLn('Min (3.14, 5): ', specialize Min<Single>(3.14, 5));
WriteLn('Min (''a'', ''b''): ', specialize Min<string>('a', 'b'));
end;
projGenericsA.lpr(29,41) Error: not yet implemented:
TInlineSpecializeExpr:TInlineSpecializeExpr [20170306102158]
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list