<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Michael Van Canneyt <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>> schrieb am Sa., 1. Juni 2019, 12:00:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On Fri, 31 May 2019, Ryan Joseph wrote:<br>
<br>
><br>
><br>
>> On May 30, 2019, at 4:18 PM, Ryan Joseph <<a href="mailto:ryan@thealchemistguild.com" target="_blank" rel="noreferrer">ryan@thealchemistguild.com</a>> wrote:<br>
>> <br>
>> I didn’t realize generic functions were in the trunk. I’m not sure I got this implemented properly so it requires some code review but can we try to include “implicitfunctionspecialization” mode switch in the next release along the with actual feature? <a href="https://bugs.freepascal.org/view.php?id=35261" rel="noreferrer noreferrer" target="_blank">https://bugs.freepascal.org/view.php?id=35261</a><br>
>> <br>
><br>
> { got blocked again, attempting to resend }<br>
><br>
> I didn’t realize generic functions were in the trunk. I’m not sure I got this implemented properly so it requires some code review but can we try to include “implicitfunctionspecialization” mode switch in the next release along the with actual feature? <a href="https://bugs.freepascal.org/view.php?id=35261" rel="noreferrer noreferrer" target="_blank">https://bugs.freepascal.org/view.php?id=35261</a><br>
><br>
> Specifically, for some time now I wanted to make a “ClearMem" function that doesn’t require passing the type but the insanely verbose syntax of generic functions makes it even longer. Honestly the syntax is so intrusive in ObjFPC mode that I would avoid using it all together. <br>
><br>
> What we have now:<br>
><br>
> var<br>
> pt: TPoint;<br>
> begin<br>
> FillChar(pt, sizeof(TPoint), 0);<br>
><br>
> Specialization with generics:<br>
><br>
> specialize ClearMem<TPoint>(pt);<br>
><br>
> With implicit specialization:<br>
><br>
> ClearMem(pt); // :)<br>
<br>
I don't think this syntax is a good idea.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It's required for Delphi compatibility. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
What with overloads ?<br>
<br>
Procedure MyProc<T>(a:T);<br>
Procedure MyProc(a : TObject);<br>
<br>
How do I know which one will be called ?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The compiler calls the more specific one. I'd need to cross check with Delphi, but here I'd assume that it would be the TObject one as no specialization is required then. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div></div>