[fpc-devel] Re: Comparison FPC 2.6.2 - Kylix 3
Daniël Mantione
daniel.mantione at freepascal.org
Mon Mar 4 14:37:40 CET 2013
Op Mon, 4 Mar 2013, schreef Mattias Gaertner:
> Can this be cached?
> Maybe the compiler can reuse some results?
No. The symtable lookups can be parsed, but the candidate selection, which
I believe is actually more compute intensive, is dependend on the actual
situation where the operator is called, for example the types of the left
and right part, which would not yield very high hit rates.
Originally the compiler was doing the candidate selection with a simple
loop through the parameters that took the first suitable match. When the
type conversion matters became more complex the "Unable to determine
overloaded procedure" error became increasingle annoying.
At some point I did redesign it with scoring system: Each candidate that
is compatible gets assigned a score how well the overloaded procedure
matches the parameters. The best match is selected.
At that point, the compiler became highly intelligent in finding the
correct overloaded procedure/operator, but the amount of computing power
involved with overloading went up: Instead of selecting the first
candidate, we need to compute the score for all candidates. This even
requires floating point arithmetic.
Daniël
More information about the fpc-devel
mailing list