<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>As I said for me then it's rather useless for what I see the
benefit in helpers for generic types.</p>
<p>It's not even close to the benefit I get from extension methods
in C# (yeah, I know generics work a bit different there).</p>
<p>Having really slim interfaces like IEnumerable<T> or
IObservable<T> which both have only one method but a ton of
extension methods that give all the power to those types is great
not only for extensibility by adding more extension methods but
also for implementing your own enumerables or observables (only
need to implement one method!).</p>
<p>Having to put those methods on the interface in pascal which is
not even possible because some of those extension methods have
more than just the one generic parameter from the type they are
extending is making this kind of code very unwieldy (you have to
write it in a reverse way wrapping static method calls into each
other rather than just chaining them together).<br>
</p>
<br>
<div class="moz-cite-prefix">Am 01.09.2017 um 18:38 schrieb Sven
Barth:<br>
</div>
<blockquote type="cite"
cite="mid:CAFMUeB8X2QfyjQT40HA0ECSrzqvwv4Cj+DoVDaND8KDF7daGXg@mail.gmail.com">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<p>Am 01.09.2017 14:50 schrieb "Stefan Glienke" <<a
href="mailto:sglienke@dsharp.org" moz-do-not-send="true">sglienke@dsharp.org</a>>:<br>
><br>
> > For generics the only way to support them is that you
must explicitly specialize a generic helper type. The compiler
won't do any type inference for you.<br>
><br>
> IMO this makes them rather useless. Is that a technical
limitation or just something you did not want to do?<br>
> I don't know much about compiler internals for forgive me
my naivety.<br>
><br>
> If I have TFoo<T> and a TFooHelper<T> and
somewhere declare a TFoo<Integer> and use a method<br>
> from my helper can't the compiler make sure to compile the
TFooHelper<Integer> version for it?</p>
<p>What if I do the initial specialization in a unit that does not
know about the helper? It can't just do speculative
specialization once both the specialized generic and the generic
helper are used in the same unit. And even if the compiler would
postpone it till some method of the specialized type is called
things would get polluted once multiple helpers lee type are
allowed as every one of the generic helpers in scope would need
to be specialized for overload resolution.</p>
<p>So in short: no, I don't *want* this, but it's due to technical
reasons.</p>
<p>> I guess it's because it does not know anymore that
TFoo<Integer> is in fact a closed generic type that was
constructed from the open geneneric type TFoo<T>?</p>
<p>The compiler can know rather easily that a type is a
specialization, but you need to keep in mind that helpers are
also active for parent types. So if you descend from a
specialization the helpers of the generic would need to be
available as well.</p>
<p>Regards,<br>
Sven</p>
</blockquote>
<br>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;">
<tr>
<td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
<td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virenfrei. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a> </td>
</tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>