[fpc-pascal] Constants in generics

Ryan Joseph ryan at thealchemistguild.com
Tue Nov 27 08:36:33 CET 2018



> On Nov 27, 2018, at 2:25 PM, denisgolovan <denisgolovan at yandex.ru> wrote:
> 
> Hi
> 
> Sorry for breaking in, but I'd like to know if this functionality supports specializing generic functions with const parameters?
> 
> BR,
> Denis

Here’s my test which seems to be working.

program gc_procs;

generic procedure DoThis<T,const U:string>(msg:string = U);
begin
	writeln(msg, ' ',sizeof(T), ' ', U);
end;

begin
	specialize DoThis<integer,'foo'>('hello world’);	// prints "hello world 4 foo"
	specialize DoThis<integer,'foo’>;			// prints “foo 4 foo"
end.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list