Thanks Sven,
Sorry if I'm bringing up obvious points. I've set "pure" to be interface-only - it's a little tricky because if you now specify it in the main source file, it says that it can't be used in the implementation section, even though, really, the main file doesn't have such section. Still, that can be dealt with.
This will require a lot of testing once I start submitting patches!
Gareth aka. Kit
On Fri 10/08/18 06:45 , "Sven Barth" sent:
Gareth sent me the following two mails in private, but they were ment for the list:
J. Gareth Moreton wrote 17 lines
J. Gareth Moreton wrote 41 lines
I hadn't thought that I need to explain that, but apparantly you haven't yet reached that far in your research of the compiler, so:
- of course I only mean that it's an interface-only modifier if there *is* an interface section; routines that are - inside a unit - only declared inside the implementation section are obviously exempt from this (thus also for the program file)
- again I wrote that I don't mean that "pure" modifies the parameters, but it modifies the meta data (most importantly checksum) of the interface section when you add a modifier flag inside the implementation section. The compiler first handles the interface sections of units and might then compile interface sections or even implementation sections of other units depending on the dependencies between the units. If a flag only appears in the implementation section than this messes up this whole thing as the other units would need to be recompiled. This is already a mess with "inline" so we don't need to do that with "pure" as well, especially as we don't need to be Delphi compatible here.
- yes, it is correct that the compiler's capability to inline depends on the order of the routine definitions. The compiler generates the code routine by routine so if the routine's body has not yet been encountered then it can't be inlined. (When using generic specializations it triggeres the generation of the specialized routine bodies before generating the routine to avoid "inline" not working for generics) For "pure" we can even go so far as to say that a routine body *must* be available to be able to call it inside another "pure" routine. Everything else would be an error.
I hope this clears things up a bit.
Regards,
Sven
