<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Am 26.04.2020 um 23:42 schrieb Benito
van der Zander:<br>
</div>
<blockquote type="cite"
cite="mid:532276e0-86b8-eca0-8126-f10c839130d9@benibela.de">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div id="smartTemplate4-template">Hi Sven,<br>
<br>
<p> </p>
<blockquote type="cite"><br>
It's not that simple. In principle you're right that the
compiler could try to merge more implementations, but this
does not depend on the declaration of the generic, but the use
of the parameter types.<br>
</blockquote>
<p>I mostly use generics for containers, especially hashmaps.
They only stores the values and never calls specific methods
on them<br>
</p>
</div>
</blockquote>
<br>
Well, nice and well for /you/ then, but there are many more uses for
generics. And as a compiler developer I /must/ think about these
cases as well.<br>
<br>
<blockquote type="cite"
cite="mid:532276e0-86b8-eca0-8126-f10c839130d9@benibela.de">
<div id="smartTemplate4-template">
<p> </p>
<blockquote type="cite"><br>
<br>
Not to mention that your TBaseHashMap would not work with
managed types...</blockquote>
</div>
<div><br>
</div>
<div>That would need be handled separately. There are probably
also people who want a container that calls .free on TObject
descendants.<br>
</div>
</blockquote>
<br>
The user should not need to care about that, especially for general
base classes.<br>
<br>
Also assume you have a record and a hashmap that stores them. Now
you add a string to the record which turns it into a managed one and
suddenly your code will no longer work, probably resulting in subtle
bugs or memory leaks. That's /not/ what should happen for merely
adding a string. It's already bad enough that this happens with the
Pascal style I/O we don't need to have this with base container
types.<br>
<br>
For calling Free we have explicit classes. But the difference
between managed types vs. not-managed types is subtle and can change
- as mentioned above - by merely adding a field.<br>
<br>
Regards,<br>
Sven<br>
</body>
</html>