<div dir="ltr"><div><div>Thanks. This is sort-of too verbose when use. I have no comments about how to define it, but when use it, can we just use:<br><br></div>ProcessArray(someintarray); ?<br><br><br></div><div>The complier should be able to "specialize" it implicitly because it knows someintarray is array of integer?<br>
<br></div><div>alternatively, how about this:<br><br></div><div><span style="font-family:courier new,monospace">var<br></span></div><div><span style="font-family:courier new,monospace"> proc_ints: specialize ProcessArray<LongInt>;<br>
</span></div><div><span style="font-family:courier new,monospace">begin<br></span></div><div><span style="font-family:courier new,monospace"> proc_ints(someintarray);<br></span></div><div><span style="font-family:courier new,monospace">end;</span><br>
</div><div><br></div><div>use it without explicit specialize is best, however.<br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/4 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>Am 04.09.2013 08:18, schrieb Xiangrong
Fang:<br>
</div><div><div class="h5">
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi There,<br>
<br>
</div>
I try to write a procedure with generic parameters, but
failed:<br>
<span style="font-family:courier new,monospace"><br>
</span></div>
<span style="font-family:courier new,monospace">type<br>
</span></div>
<span style="font-family:courier new,monospace"> generic
TArray<T> = array of T;<br>
<br>
</span></div>
<span style="font-family:courier new,monospace">procedure
ProcessArray(arr: TArray<T>);<br>
begin<br>
end;</span><br>
<br>
<br>
</div>
<div>The compiler said "Generics without specialization cannot
be used..."<br>
<br>
</div>
<div>But if I specialize the parameter then this procedure is
useless.<br>
<br>
</div>
<div>Any ideas?<br>
<br>
</div>
</div>
</blockquote></div></div>
This is not yet supported. A proof of concept implementation exists
locally on my computer however. It will then look like this:<br>
<br>
=== code begin ===<div class="im"><br>
<br>
type<br>
generic TArray<T> = array of T;<br>
<br></div>
generic procedure ProcessArray<T>(arr: TArray<T>);<br>
begin<br>
end;<br>
<br>
begin<br>
// usage:<br>
specialize ProcessArray<LongInt>(someintarray);<br>
end.<br>
<br>
=== code end ===<br>
<br>
Regards,<br>
Sven<br>
</div>
<br>_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div><br></div>