<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Hairy Pixels via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Mo., 25. Apr. 2022, 10:58:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Apr 25, 2022, at 2:39 PM, Martin Frb via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> wrote:<br>
> <br>
> Actually, it's dealing with SmallInt (or ShortInt). And if the programmer does not know that, then it might be an issue...<br>
> <br>
> Imagine the generic code (something more complex than "Add") would somehow do something that differs for SmallInt and Integer. Like using "SizeOf(T)".<br>
<br>
This is almost a case that requires better type restrictions. If your generic function relies specifically on some particular type information this is almost not really even a good candidate to be generic at all.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Then you don't think creative enough. Think about (de)serialization code for binary data which needs to use the correct size. If done correctly this can very well be handled with a generic. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </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">
</blockquote></div></div></div>