<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Am 15.12.2024 um 13:11 schrieb Hairy
Pixels via fpc-pascal:<br>
</div>
<blockquote type="cite"
cite="mid:CAGsUGtk7nKrBq8Je6itr2Bk-jwJZVuHh8XgU-Mgyd3+sYxdmdw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Dec 15, 2024 at 6:28:25 PM,
Hairy Pixels <<a href="mailto:genericptr@gmail.com"
moz-do-not-send="true" class="moz-txt-link-freetext">genericptr@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"
type="cite"> Also noteworthy is ISO standard can accommodate
generics which Borland’s design can not. </blockquote>
</div>
<br>
<div dir="ltr">Wait, I’m wrong on this, you can use generic proc
types. The problem with generics are pointers to T. For example
that below is not possible.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">
<div dir="ltr">type</div>
<div dir="ltr"> generic TFindNodeComparator<T> =
function(item: ^T): Boolean;</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">generic function FindNode<T>(func:
specialize TFindNodeComparator<T>): ^T;</div>
</div>
</blockquote>
<br>
It's not as if it is impossible to workaround this limitation:<br>
<br>
=== code begin ===<br>
<br>
program tpointerrec;<br>
<br>
{$mode objfpc}<br>
{$modeswitch advancedrecords}<br>
<br>
type<br>
generic TPointer<T> = record<br>
type<br>
PT = ^T;<br>
end;<br>
<br>
generic TFindNodeComparator<T> = function(item: specialize
TPointer<T>.PT): Boolean;<br>
<br>
generic function FindNode<T>(func: specialize
TFindNodeComparator<T>): specialize TPointer<T>.PT;<br>
begin<br>
end;<br>
<br>
function Compare(item: specialize TPointer<LongInt>.PT):
Boolean;<br>
begin<br>
end;<br>
<br>
begin<br>
specialize FindNode<LongInt>(@Compare);<br>
end.<br>
<br>
=== code end ===<br>
<br>
Regards,<br>
Sven<br>
</body>
</html>