On Sat, 13 Jul 2019, Ben Grasset wrote:

On Sat, Jul 13, 2019 at 3:47 PM Michael Van Canneyt <mich...@freepascal.org>
wrote:

No doubt, but this will lead to a bloated binary. I want less code (both
source and assembler), not more.


Well, it would be one instantiation per unique type it was used on.

I know. See below.


So if you had five hand-written helper functions for different types, and
replaced all of them with the use of a single generic function, you'd still
end up with just five functions worth of assembler code (i.e. the same
amount you had to begin with.)

Yes, I know. But the goal is to have 'is/as'. Then there is at best only 1 
helper
function for all enumerateds.

I have a Delphi project that uses really lots of generics. The decrease in
compilation speed and increase in binary size is truly noticeable.

<aside>
In general, I strive to minimalize the use of generics or avoid them at all. IMO there are little use cases that really justify the use of generics. But that's a highly personal opinion.
</aside>

Michael.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to